RAS 19.1 script changes from the 18.1 script
Produced: 12/6/2022 6:29:49 AM
   
Mode:  Differences  
Left file: C:\gitstuff\Parallels-RAS-V19.x-Doc-Script-3.00\RAS_Inventory_V2.5.ps1  
Right file: C:\gitstuff\Parallels-RAS-V19.x-Doc-Script-3.00\RAS_Inventory_V3_0.ps1  
        Creates a complete inventory of a V18.1 or later Parallels Remote Application Server. <>         Creates a complete inventory of a V19.x or later Parallels Remote Application Server.
 
        Creates a complete inventory of a V18.1 or later Parallels Remote Application Server  <>         Creates a complete inventory of a V19.x or later Parallels Remote Application Server 
 
        June 1, 2021 at 6PM is 2021-06-01_1800. <>         June 1, 2023 at 6PM is 2023-06-01_1800.
 
        Output filename will be ReportName_2021-06-01_1800.<ext>. <>         Output filename will be ReportName_2023-06-01_1800.<ext>.
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -RASSite EMEASite <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -RASSite EMEASite
 
        PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -MSWord -CompanyName "Carl Webster  <>         PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -MSWord -CompanyName "Carl Webster 
 
        PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -PDF -CN "Carl Webster Consulting" -CP  <>         PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -PDF -CN "Carl Webster Consulting" -CP 
 
        PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -CompanyName "Sherlock Holmes  <>         PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -CompanyName "Sherlock Holmes 
 
        PS C:\PSScript .\RAS_Inventory_V2.5.ps1 -CompanyName "Sherlock Holmes  <>         PS C:\PSScript .\RAS_Inventory_V3.0.ps1 -CompanyName "Sherlock Holmes 
 
        PS C:\PSScript >.\RAS_Inventory_V2.5.ps1 -Dev -ScriptInfo -Log <>         PS C:\PSScript >.\RAS_Inventory_V3.0.ps1 -Dev -ScriptInfo -Log
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer mail.domain.tld -From  <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer mail.domain.tld -From 
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer mailrelay.domain.tld -From  <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer mailrelay.domain.tld -From 
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer  <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer 
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer smtp.office365.com -SmtpPort 587 <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer smtp.office365.com -SmtpPort 587
 
        PS C:\PSScript > .\RAS_Inventory_V2.5.ps1 -SmtpServer smtp.gmail.com -SmtpPort 587 <>         PS C:\PSScript > .\RAS_Inventory_V3.0.ps1 -SmtpServer smtp.gmail.com -SmtpPort 587
 
        NAME: RAS_Inventory_V2.5.ps1 <>         NAME: RAS_Inventory_V3.0.ps1
        VERSION: 2.53           VERSION: 3.00
 
        LASTEDIT: February 13, 2022 <>         LASTEDIT: December 6, 2022
 
# <>  
#Version 2.53 13-Feb-2022    
#       When processing RD Session Hosts, the script had bad logic that assumed there was always only one RDS Group.    
#               This caused some Agent settings to show as System.Object[] instead of their Numeric or Boolean value    
#               For example:    
#                       Agent settings    
#                               Port                                                  : System.Object[]    
#                               Max Sessions                                          : System.Object[]    
#                               Support Windows Shell URL namespace objects           : System.Object[]    
#                               Allow 2xRemoteExec to send command to the client      : System.Object[]    
#                               Use RemoteApp if available                            : System.Object[]    
#                               Enable applications monitoring                        : System.Object[]    
#                               Allow file transfer command (HTML5 and Chrome clients): System.Object[]    
#                               Do not allow to change location                       : System.Object[]    
#                               Enable drive redirection cache                        : System.Object[]    
#               Oops, my bad. The fix only took one line of code and changing two variables.    
#               Now the results are correct.    
#                       Agent settings    
#                               Port                                                  : 3389    
#                               Max Sessions                                          : 25    
#                               Support Windows Shell URL namespace objects           : True    
#                               Allow 2xRemoteExec to send command to the client      : True    
#                               Use RemoteApp if available                            : False    
#                               Enable applications monitoring                        : True    
#                               Allow file transfer command (HTML5 and Chrome clients): True    
#                               Do not allow to change location                       : False    
#                               Enable drive redirection cache                        : True    
#               Thanks to Thomas Krampe for all his help and remote sessions to track this down    
#    
#Version 2.52 7-Feb-2022    
#       Added Function GetRASStatus to return the full status text for several RAS Status cmdlets    
#               Updated all AgentState outputs to use the value from GetRASStatus    
#       Added HALB output    
#               Virtual Servers    
#                       Properties    
#                       General    
#                       LB gateway payload    
#                       LB SSL payload    
#                       Devices    
#                       Advanced    
#       Changed the date format for the transcript and error log files from yyyy-MM-dd_HHmm format to the FileDateTime format    
#               The format is yyyyMMddTHHmmssffff (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day,     
#               the letter T as a time separator, 2-digit hour, 2-digit minute, 2-digit second, and 4-digit millisecond).     
#               For example: 20221225T0840107271.    
#       Fixed call to Get-RASThemeFooterURL to always return an array (Thanks to Thomas Krampe for the debugging time)    
#       Fixed missing RDS Group Default settings (Thanks to Thomas Krampe)    
#       Fixed several logic errors where I assumed there were always RDS groups    
#       Fixed the German Table of Contents (Thanks to Rene Bigler)    
#               From     
#                       'de-'   { 'Automatische Tabelle 2'; Break }    
#               To    
#                       'de-'   { 'Automatisches Verzeichnis 2'; Break }    
#       For Policy setting Session/Connection/Primary connection/Login/Auto Login, change property name AutoStart to AutoLogin    
#       In Function AbortScript, add test for the winword process and terminate it if it is running    
#               Added stopping the transcript log if the log was enabled and started    
#       In Function OutputFarmSite, only get the first Publishing Agent server for the Farm/Site settings    
#       In Functions AbortScript and SaveandCloseDocumentandShutdownWord, add code from Guy Leech to test for the "Id" property before using it    
#       Replaced most script Exit calls with AbortScript to stop the transcript log if the log was enabled and started    
#       Updated the help text    
#       Updated the ReadMe file    
#       Updated to allow running the script for RAS versions greater than 18.1    
#    
#Version 2.51 11-Sep-2021    
#       Added array error checking for non-empty arrays before attempting to create the Word table for most Word tables    
#       Added Function OutputReportFooter    
#       Added Parameter ReportFooter    
#               Outputs a footer section at the end of the report.    
#               Report Footer    
#                       Report information:    
#                               Created with: <Script Name> - Release Date: <Script Release Date>    
#                               Script version: <Script Version>    
#                               Started on <Date Time in Local Format>    
#                               Elapsed time: nn days, nn hours, nn minutes, nn.nn seconds    
#                               Ran from domain <Domain Name> by user <Username>    
#                               Ran from the folder <Folder Name>    
#       Updated Functions SaveandCloseTextDocument and SaveandCloseHTMLDocument to add a "Report Complete" line    
#       Updated Functions ShowScriptOptions and ProcessScriptEnd to add $ReportFooter    
#       Updated the help text    
#       Updated the ReadMe file    
#    
#Version 2.50 12-Aug-2021    
#       Added a version test so the script only works with RAS 18.1    
#       Added documenting (my best attempt) an Azure provider connection    
#       Added Certificates    
#               Alternate Names    
#               General    
#                       Alternate Names    
#       Added Policies summary    
#       Added Policy Properties (took five days for this one section)    
#               Policy    
#               Policy/Criteria    
#               Session    
#               Session/Connection    
#               Session/Connection/Primary connection    
#               Session/Connection/Secondary connections    
#               Session/Connection/Reconnection    
#               Session/Connection/Computer name    
#               Session/Connection/Advanced settings    
#               Session/Connection/Web authentication    
#               Session/Connection/Multifactor authentication    
#               Session/Connection/Session prelaunch    
#               Session/Connection/Local proxy address    
#               Session/Display    
#               Session/Display/Settings    
#               Session/Display/Multi-monitor    
#               Session/Display/Published applications    
#               Session/Display/Desktop options    
#               Session/Display/Browser    
#               Session/Printing    
#               Session/Scanning    
#               Session/Audio    
#               Session/Keyboard    
#               Session/Local devices and resources    
#               Session/Local devices and resources/Clipboard    
#               Session/Local devices and resources/Disk drives    
#               Session/Local devices and resources/Devices    
#               Session/Local devices and resources/Video capture devices (not in PowerShell yet)    
#               Session/Local devices and resources/Ports    
#               Session/Local devices and resources/Smart cards    
#               Session/Local devices and resources/Windows touch input    
#               Session/Local devices and resources/File transfer    
#               Session/Experience    
#               Session/Experience/Performance    
#               Session/Experience/Compression    
#               Session/Network    
#               Session/Server authentication    
#               Session/Advanced settings    
#               Client options    
#               Client options/Connection    
#               Client options/Logging    
#               Client options/Update    
#               Client options/PC keyboard    
#               Client options/Single Sign-On    
#               Client options/Advanced    
#               Client options/Advanced/Global    
#               Client options/Advanced/Language    
#               Client options/Advanced/Printing    
#               Client options/Advanced/Windows client    
#               Client options/Advanced/RemoteFX USB redirection    
#               Control settings    
#               Control settings/Connections    
#               Control settings/Password    
#               Control settings/Import and export    
#               Redirection    
#       Added Reporting    
#               RAS reporting configuration    
#                       Session information    
#                       Server counters information    
#                       Custom reports    
#               RAS Performance Monitor configuration    
#       Added Themes    
#               General    
#               Messages    
#               HTML5 client/Branding    
#               HTML5 client/Language bar    
#               HTML5 client/Messages    
#               HTML5 client/Gateway    
#               HTML5 client/Legal policies    
#               Windows client/Branding    
#               Windows client/Messages    
#               Windows client/Custom menu    
#       Added to Connection/Multi-factor authentication:    
#               Enable MFA for all users except    
#               Disable MFA for all users except    
#               User or group list    
#               Updated all items and text to match the console (a lot of work)    
#               Added for Azure RADIUS, Duo RADIUS, FortiAuthenticator RADIUS, TekRADIUS, and RADIUS    
#                       Connection    
#                       Attributes    
#                       Automation    
#               Added DeepNet Provider    
#                       Connection    
#                       Application    
#                       Authentication    
#               Added SafeNet Provider    
#                       Connection    
#                       Authentication    
#               Added Google Authenticator    
#                       General    
#       Added to Gateway and Gateway Default Settings:    
#               HTML5/Allow cross-origin resource sharing    
#                       Domains for cross-origin resource sharing    
#                       Browser cache time in months    
#               HTML5/Clipboard redirection    
#               HTML5/File Transfer Direction    
#               HTML5/Use ciphers according to server preference    
#               Wyse/Do not warn if server certificate is not verified    
#       Added to Provider/Agent settings Drag and drop    
#       Added to Published Items their Status    
#               Disabled    
#               Enabled    
#               In maintenance    
#       Added to RD Session Host, RD Session Host Groups, Provider and Default Site Settings:    
#               Agent settings/File Transfer Direction    
#               Agent settings/File Transfer Location    
#               Agent settings/File Transfer Do not allow to change location    
#       Change the wording in Connection/Authentication and Multi-factor authentication to match the console    
#       Fixed a lot of HTML and text formatting issues    
#       In Certificates/General, moved Expiration date to before Common name    
#       In Published Resources, only show Associated File Extensions if the EnableFileExtensions property is True    
#               If you add file extensions and later disable file extensions, the extensions previously entered are still there    
#       Renamed in Gateway/SSL/TLS/HSTS settings "Max-age" to "Browse cache time in months"    
#       Renamed in RDS Host/Agent, RDS Group/Agent, and Provider/Agent settings:    
#               "Support Shell URL namespace objects" to "Support Windows Shell URL namespace objects"    
#       Removed the Restrictions label from Gateways/HTML5 as it is no longer in the console    
#       Updated Function GetVDIType with Hypervisor data for ESXi 7.0 and vCenter 7.0    
#       Updated the Help text    
#       Updated the ReadMe file    
#    
#Version 2.10 25-Apr-2021   #Work on 3.0 started on 15-Nov-2022
#       Fixed wrong variables used to determine User Profile technology    
#       For RD Session Hosts properties:    
#               Renamed the Properties tab to General    
#               Renamed Agent Settings to Agent settings    
#               Renamed User Profile to User profile    
#               Renamed Desktop Access to Desktop access    
#               Renamed RDP Printer to RDP printer    
#       For RD Session Hosts Groups properties:    
#               Renamed Agent Settings to Agent settings    
#               Renamed Desktop Access to Desktop access    
#               Renamed RDP Printer to RDP printer    
#       For RD Session Hosts Schedule properties:    
#               Renamed the Properties tab to General    
#       For VDI Providers properties:    
#               Renamed Agent Settings to Agent settings    
#               Renamed RDP Printer to RDP printer    
#       For Gateways properties:    
#               Renamed the Properties tab to General    
#       For Certificates properties:    
#               Renamed the Properties tab to General    
#       For Administration, Settings:    
#               Rename Customer Experience Program to Customer experience program    
#               Rename HTTP Proxy settings to HTTP proxy settings    
#       For License:    
#               Rename License Details to License details    
#       For VDI, the following changes were made:    
#               Providers tab, added Direct address    
#               Providers properties, renamed the Properties tab to General    
#               Providers properties, Agent settings:    
#                       Removed "Publishing Session Timeout"    
#                       Added "Enable drive redirection cache"    
#               Pools tab:    
#                       Pools:    
#                               Added Last modification by    
#                               Added Modified on    
#                               Added Created by    
#                               Added Created on    
#               Templates tab:    
#                       For template properties, removed Status as I was getting the wrong status property    
#                       Template properties, renamed the Properties tab to General    
#                       Advanced tab, renamed Native Pool to Resource pool    
#       Updated the ReadMe file    
#    
#Version 2.00 20-Apr-2021    
#       Added 59 RDS Agent States    
#       Added a message to the error message for the missing RAS module    
#               Added a link to the V2 ReadMe file    
#       Added a parameter, RASSite, allowing the report to contain data for the specified Site    
#       Added additional Notification handlers types    
#       Added FSLogix to Farm/Site/Settings/Features    
#       Added Function GetFarmSites    
#       Added the missing License section for published RDSH applications to Text and HTML output    
#       Added to Universal Printing/Printer drivers, "Settings are replicated to all Sites"    
#       Added UPD and FSLogix to the User Profile tab for both RD Session Hosts and RD Session Hosts/Groups    
#       Added VDI Pool Member type of "ALLGUESTSONPROVIDER"    
#       Added WVD Apps and Desktops to Publishing    
#       Changed $DesktopSize to use the new values of the DesktopSize property    
#               Removed the property UseAvailableArea as it no longer exists    
#       Changed all RAS cmdlet names to use the new naming scheme Get-RAS*    
#       Changed all Write-Verbose statements from Get-Date to Get-Date -Format G as requested by Guy Leech    
#       Changed Get-RASVDIHost to the new Get-RASProvider    
#       Changed Get-RASVDIHostStatus to the new Get-RASProviderStatus    
#       Changed PoSH module from PSAdmin to RASAdmin    
#       Changed some Write-Warnings to Write-Host as they are not warnings    
#               Reformat most of the Write-Host statements to make the console output look better    
#       Changed the font size of Word/PDF tables from 11 to 10 to prevent most word wrapping to multiple lines    
#       Changed the RDS User Profile Technology to one line instead of two    
#       Changed the variable $MasterPublishingAgent to $PrimaryPublishingAgent    
#               Changed the matching column headings from Master Publishing Agent to Primary Publishing Agent    
#       Changed TWAIN and WIA state from "Unable to retrieve ___ Scanning information" to $False if unable to retrieve data or retrieved no data    
#       Fixed several alignment issues in the text output    
#       Fixed several formatting issues with the HTML and Word/PDF output    
#       Fixed several invalid $Null comparisons    
#       For RD Session Hosts, Agent settings, add the option Enable drive redirection cache    
#       For replicating settings, standardized on the wording "Settings are replicated to all Sites" followed by True or False    
#       In the Administration section, add the following:    
#               Accounts, Receive system notifications    
#               Settings, Miscellaneous, Reset idle RAS Console session after    
#       In the Connection section, add the following:    
#               Allowed devices, headings for Secure Access and Device Access    
#               Allowed devices, Allow only clients with the latest security patches    
#               Allowed devices, Device Access, Mode text label    
#       In the Filters section, reformatted the output to make it more readable (at least to me)    
#       In the Load Balancing section added CPU Optimization    
#       Moved Notification from Administration to Site Settings    
#       Removed all Turbo.net content    
#       Removed Function ProcessSites    
#       Removed MaxGuests from Provider/Agent Settings    
#       Removed property EnableCPULB from Load Balancing section    
#       Removed UPD settings from RD Session Hosts properties and Groups properties    
#       Reorder Parameters in an order recommended by Guy Leech    
#       Reworked how the script processed a Farm with multiple Sites    
#               For most of the Get-RAS* cmdlets, where needed, added the -Site parameter    
#       Updated Function SetWordCellFormat to the latest version    
#       Updated the Allowed authentication types to the new text in the console and handled multiple selections    
#       Updated the help text    
#       Updated the ReadMe file    
#       When retrieving data for Gateways, set variables to values specifying if the Gateway data could not be retrieved or found no Gateway data    
#       When using the output from Get-RASVDITemplate, change VDIHostId to ProviderId    
#       With the addition of the "Last modification by", "Modified on", "Created by", and "Created on"     
#               properties to the PowerShell cmdlets, add those four properties to the relevant report sections    
 
  -+ $SaveEAPreference         = $ErrorActionPreference
    $ErrorActionPreference    = 'SilentlyContinue'
    $Error.Clear()
     
 
$script:MyVersion         = '2.53' <> $script:MyVersion         = '3.00.016'
$Script:ScriptName        = "RAS_Inventory_V2.5.ps1"   $Script:ScriptName        = "RAS_Inventory_V3.0.ps1"
$tmpdate                  = [datetime] "02/13/2022"   $tmpdate                  = [datetime] "12/06/2022"
 
        [int]$wdColorBlack            = 0 <>         #[int]$wdColorBlack            = 0
        [int]$wdColorGray05           = 15987699            #[int]$wdColorGray05           = 15987699 
 
        [int]$wdColorRed              = 255 <>         #[int]$wdColorRed              = 255
 
        [int]$wdColorYellow           = 65535 <>         #[int]$wdColorYellow           = 65535
 
        [int]$wdAlignParagraphLeft = 0 <>         #[int]$wdAlignParagraphLeft = 0
        [int]$wdAlignParagraphCenter = 1           #[int]$wdAlignParagraphCenter = 1
        [int]$wdAlignParagraphRight = 2           #[int]$wdAlignParagraphRight = 2
 
        [int]$wdCellAlignVerticalTop = 0 <>         #[int]$wdCellAlignVerticalTop = 0
        [int]$wdCellAlignVerticalCenter = 1           #[int]$wdCellAlignVerticalCenter = 1
        [int]$wdCellAlignVerticalBottom = 2           #[int]$wdCellAlignVerticalBottom = 2
 
        [int]$wdAutoFitWindow = 2 <>         #[int]$wdAutoFitWindow = 2
 
        [int]$wdAdjustNone = 0 <>         #[int]$wdAdjustNone = 0
 
        [int]$wdAdjustFirstColumn = 2 <>         #[int]$wdAdjustFirstColumn = 2
        [int]$wdAdjustSameWidth = 3           #[int]$wdAdjustSameWidth = 3
 
        [int]$Indent1TabStops = 1 * $PointsPerTabStop <>         #[int]$Indent1TabStops = 1 * $PointsPerTabStop
        [int]$Indent2TabStops = 2 * $PointsPerTabStop           #[int]$Indent2TabStops = 2 * $PointsPerTabStop
        [int]$Indent3TabStops = 3 * $PointsPerTabStop           #[int]$Indent3TabStops = 3 * $PointsPerTabStop
        [int]$Indent4TabStops = 4 * $PointsPerTabStop           #[int]$Indent4TabStops = 4 * $PointsPerTabStop
 
  -+         [int]$wdStyleHeading5 = -6
 
        [int]$wdTableLightListAccent3 = -206 <>         #[int]$wdTableLightListAccent3 = -206
 
  -+         $Script:myHash.Word_Heading5        = $wdStyleheading5
 
  -+                 5 {$Script:Selection.Style = $Script:MyHash.Word_Heading5; Break}
 
        Write-Verbose "$(Get-Date -Format G): RAS Version          : $($Script:RASVersion)" +-  
 
  -+                 $Script:RASFullVersion = $Results
 
                If([version]$Script:RASVersion -ge [version]"18.1") <>                 If([version]$Script:RASVersion -ge [version]"19.1")
 
        This script is designed for RAS 18.1 and should not be run on $Results. <>         This script is designed for RAS 19.1 and should not be run on $Results.
 
        If you are running RAS 18.0, please use:  <>         If you are running RAS 18.x, please use: 
 
  -+                 $Script:RASFullVersion = "Unable to determine"
 
        This script is designed for RAS 18.1 and your RAS version could not be determined. <>         This script is designed for RAS 19.1 and your RAS version could not be determined.
 
        If you are running RAS 18.0, please use:  <>         If you are running RAS 18.x, please use: 
 
                Out-File -FilePath $SIFile -Append -InputObject "RAS Version          : $Script:RASVersion" 4>$Null +-  
 
        $Results = Get-RASFarmSettings -EA 0 <>         $Results = Get-RASFarmSettings -EA 0 4>$Null
 
                 +-  
                OutputFarm    
 
        Write-Verbose "$(Get-Date -Format G): `tRetrieving Farm Sites" <>         #Write-Verbose "$(Get-Date -Format G): `tRetrieving Farm Sites"
 
                $Results = Get-RASPA -SiteId $Site.Id -EA 0 4> $Null | Select -First 1 #changed in 2.52 to only get the first PA <>                 $Results = Get-RASBroker -SiteId $Site.Id -EA 0 4> $Null | Select-Object -First 1 #changed in 2.52 to only get the first PA
 
                $ScriptInformation.Add(@{Data = "Primary Publishing Agent"; Value = $PrimaryPublishingAgent; }) > $Null <>                 $ScriptInformation.Add(@{Data = "Primary Connection Broker"; Value = $PrimaryPublishingAgent; }) > $Null
 
                Line 1 "Site`t`t`t: " $Site.Name <>                 Line 1 "Site`t`t`t : " $Site.Name
                Line 1 "Primary Publishing Agent: " $PrimaryPublishingAgent                   Line 1 "Primary Connection Broker: " $PrimaryPublishingAgent
                Line 1 "Type`t`t`t: " $Type                   Line 1 "Type`t`t`t : " $Type
                Line 1 "State`t`t`t: " $State                   Line 1 "State`t`t`t : " $State
                Line 1 "Description`t`t: " $Description                   Line 1 "Description`t`t : " $Description
                Line 1 "ID`t`t`t: " $ID                   Line 1 "ID`t`t`t : " $ID
                Line 1 "Last modification by`t: " $Site.AdminLastMod                   Line 1 "Last modification by`t : " $Site.AdminLastMod
                Line 1 "Modified on`t`t: " $Site.TimeLastMod.ToString()                   Line 1 "Modified on`t`t : " $Site.TimeLastMod.ToString()
                Line 1 "Created by`t`t: " $Site.AdminCreate                   Line 1 "Created by`t`t : " $Site.AdminCreate
                Line 1 "Created on`t`t: " $Site.TimeCreate.ToString()                   Line 1 "Created on`t`t : " $Site.TimeCreate.ToString()
 
                $rowdata += @(,("Primary Publishing Agent",($Script:htmlsb),$PrimaryPublishingAgent,$htmlwhite)) <>                 $rowdata += @(,("Primary Connection Broker",($Script:htmlsb),$PrimaryPublishingAgent,$htmlwhite))
 
  -+                 "HyperVWin2022Std"                                      {$VDIType = "HyperV on Windows Server 2022 Standard Edition"; Break}
                    "HyperVWin2022Dtc"                                      {$VDIType = "HyperV on Windows Server 2022 Datacenter Edition"; Break}
 
  -+                 "HyperVFailoverClusterWin2022"          {$VDIType = "HyperV Failover Cluster on Windows Server 2022"; Break}
 
  -+                 15                                                                      {$VDIType = "Vmware VCenter Server 7.0"; Break}
 
  <>                 "Nutanix5_5"                                            {$VDIType = "Nutanix 5.5"; Break}
                    "Nutanix5_10"                                           {$VDIType = "Nutanix 5.10"; Break}
                    "Nutanix5_15"                                           {$VDIType = "Nutanix 5.15"; Break}
                    "Nutanix5_20"                                           {$VDIType = "Nutanix 5.20"; Break}
                    "Nutanix6_5"                                            {$VDIType = "Nutanix 6.5"; Break}
                "RemotePCUnknown"                                       {$VDIType = "Remote PC Unknown"; Break}                   "RemotePCStaticUnknown"                         {$VDIType = "Remote PC static unknown"; Break}
 
  -+                 "RemotePCDynamicUnknown"                        {$VDIType = "Remote PC dynamic unknown"; Break}
 
  -+                 "Scale"                                                         {$VDIType = "Scale unknown"; Break}
 
  <>                 "Scale8_6_5"                                            {$VDIType = "Scale 8.6.5"; Break}
                    "Scale8_8"                                                      {$VDIType = "Scale 8.8"; Break}
                    "Scale8_9"                                                      {$VDIType = "Scale 8.9"; Break}
                    "Scale9_1"                                                      {$VDIType = "Scale 9.1"; Break}
                "Azure"                                                         {$VDIType = "Azure"; Break}                                                        "Azure"                                                         {$VDIType = "Azure"; Break}
                    21                                                                      {$VDIType = "Azure"; Break}
                    "AzureUnknown"                                          {$VDIType = "Azure"; Break}                                     
                    "AVD"                                                           {$VDIType = "AVD"; Break}                                       
                    "AWSEC2"                                                        {$VDIType = "AWSEC2"; Break}                                    
 
  -+                 #""                                             {$FullRASStatus = ""; Break}
                    "AddingMembers"                                 {$FullRASStatus = "Guest being added to the group"; Break}
 
  -+                 "DeleteInProgress"                              {$FullRASStatus = "A delete is currently in progress"; Break}
 
  -+                 "FailedPerfCounters"                    {$FullRASStatus = "Performance counters failed to initialize"; Break}
 
  -+                 "JoiningToGroup"                                {$FullRASStatus = "A host is current being joined to a group or hostpool"; Break}
 
  -+                 "NoAvailableGateways"                   {$FullRASStatus = "There are no RAS Secure Gateways that the Tenant Broker can use to process connections"; Break}
 
  -+                 "PendingRecreation"                             {$FullRASStatus = "Machine will be recreated on the last user logoff"; Break}
 
  -+                 "RemovingMembers"                               {$FullRASStatus = "Guest being removed from the group"; Break}
                    "ScalingIn"                                             {$FullRASStatus = "Deprecated: use RemovingMembers instead"; Break}
                    "ScalingOut"                                    {$FullRASStatus = "Deprecated: use AddingMembers instead"; Break}
 
                                Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)` <>                                 Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)`
 
                                        WriteWordLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)"
 
                                        Line 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         Line 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve RDS Status for RDS Host $($RDSHost.Server)"
 
                                No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)` <>                                 No RDS Status retrieved for RDS Host $($RDSHost.Server)`
 
                                        WriteWordLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         WriteWordLine 0 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)"
 
                                        Line 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         Line 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)"
 
                                        WriteHTMLLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         WriteHTMLLine 0 0 "No RDS Status retrieved for RDS Host $($RDSHost.Server)"
 
                                        $ScriptInformation.Add(@{Data = "Address"; Value = $RDSHost.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Name"; Value = $RDSHost.Server; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $RDSStatus.PreferredPA; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $RDSStatus.PreferredBroker; }) > $Null
 
                                        $Table.Columns.Item(2).Width = 250; <>                                         $Table.Columns.Item(2).Width = 300;
 
                                        Line 2 "Address`t`t: " $RDSHost.Server <>                                         Line 2 "Name`t`t`t`t: " $RDSHost.Server
                                        Line 2 "Status`t`t: " $RDSStatusAgentState                                           Line 2 "Status`t`t`t`t: " $RDSStatusAgentState
                                        Line 2 "CPU`t`t: " "$($RDSStatus.CPULoad)%"                                           Line 2 "CPU`t`t`t`t: " "$($RDSStatus.CPULoad)%"
                                        Line 2 "RAM`t`t: " "$($RDSStatus.MemLoad)%"                                           Line 2 "RAM`t`t`t`t: " "$($RDSStatus.MemLoad)%"
                                        Line 2 "Disk read time`t: " "$($RDSStatus.DiskRead)%"                                           Line 2 "Disk read time`t`t`t: " "$($RDSStatus.DiskRead)%"
                                        Line 2 "Disk write time`t: " "$($RDSStatus.DiskWrite)%"                                           Line 2 "Disk write time`t`t`t: " "$($RDSStatus.DiskWrite)%"
                                        Line 2 "Sessions`t: " $Sessions                                           Line 2 "Sessions`t`t`t: " $Sessions
                                        Line 2 "Preferred PA`t: " $RDSStatus.PreferredPA                                           Line 2 "Preferred Connection Broker`t: " $RDSStatus.PreferredBroker
                                        Line 2 "Operating system: " $RDSStatus.ServerOS                                           Line 2 "Operating system`t`t: " $RDSStatus.ServerOS
                                        Line 2 "Agent version`t: " $RDSStatus.AgentVer                                           Line 2 "Agent version`t`t`t: " $RDSStatus.AgentVer
 
                                        $columnHeaders = @("Address",($Script:htmlsb),$RDSHost.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$RDSHost.Server,$htmlwhite)
 
                                        $rowdata += @(,("Preferred PA",($Script:htmlsb),$RDSStatus.PreferredPA,$htmlwhite)) <>                                         $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$RDSStatus.PreferredBroker,$htmlwhite))
 
                                        $columnWidths = @("200","275") <>                                         $columnWidths = @("200","350")
 
  <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Providers"
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Providers"
            }
            If($Text)
            {
                    Line 1 "Providers"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Providers"
            }
     
        $VDIHosts = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null           $Providers = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve VDI for Site $($Site.Name)` <>                 Unable to retrieve Providers for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve VDI for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve Providers for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $VDIHosts) <>         ElseIf($? -and $Null -eq $Providers)
 
                No VDI retrieved for Site $($Site.Name).` <>                 No Providers retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No VDI retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No Providers retrieved for Site $($Site.Name)"
 
                        Line 0 "No VDI retrieved for Site $($Site.Name)" <>                         Line 0 "No Providers retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No VDI retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No Providers retrieved for Site $($Site.Name)"
 
                If($MSWord -or $PDF) <>  
                {    
                        WriteWordLine 2 0 "VDI Providers"                   ForEach($Provider in $Providers)
                }    
                If($Text)    
 
                        Line 1 "VDI Providers" <>  
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "VDI Providers"    
                }    
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput VDI Providers"    
                ForEach($VDIHost in $VDIHosts)    
                {    
                        $VDIHostStatus = Get-RASProviderStatus -Id $VDIHost.Id -EA 0 4>$Null                           $Providerstatus = Get-RASProviderStatus -Id $Provider.Id -EA 0 4>$Null
 
                                Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)` <>                                 Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)`
 
                                        WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"
 
                                        Line 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)" <>                                         Line 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($Provider.Id)"
 
                        ElseIf($? -and $Null -eq $VDIHostStatus) <>                         ElseIf($? -and $Null -eq $Providerstatus)
 
                                No VDI Host Status retrieved for VDI Host $($VDIHost.Id)` <>                                 No VDI Host Status retrieved for VDI Host $($Provider.Id)`
 
                                        WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)" <>                                         WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"
 
                                        Line 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)" <>                                         Line 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"
 
                                        WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)" <>                                         WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($Provider.Id)"
 
                                $FullProviderStatus = GetRASStatus $VDIHostStatus.AgentState <>                                 $FullProviderStatus = GetRASStatus $Providerstatus.AgentState
 
                                        $ScriptInformation.Add(@{Data = "Address"; Value = $VDIHost.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Server; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($VDIHostStatus.CPULoad)%"; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "CPU"; Value = "$($Providerstatus.CPULoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($VDIHostStatus.MemLoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "RAM"; Value = "$($Providerstatus.MemLoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($VDIHostStatus.DiskRead)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($Providerstatus.DiskRead)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($VDIHostStatus.DiskWrite)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($Providerstatus.DiskWrite)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $VDIHostStatus.PreferredPA; }) > $Null                                           $ScriptInformation.Add(@{Data = "Preferred COnnection Broker"; Value = $Providerstatus.PreferredBroker; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $VDIHostStatus.ServerOS; }) > $Null                                           $ScriptInformation.Add(@{Data = "Operating system"; Value = $Providerstatus.ServerOS; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $VDIHostStatus.AgentVer; }) > $Null                                           $ScriptInformation.Add(@{Data = "Agent version"; Value = $Providerstatus.AgentVer; }) > $Null
 
                                        $Table.Columns.Item(2).Width = 250; <>                                         $Table.Columns.Item(2).Width = 300;
 
                                        Line 2 "Address`t`t: " $VDIHost.Server <>                                         Line 2 "Name`t`t`t`t: " $Provider.Server
                                        Line 2 "Status`t`t: " $FullProviderStatus                                           Line 2 "Status`t`t`t`t: " $FullProviderStatus
                                        Line 2 "CPU`t`t: " "$($VDIHostStatus.CPULoad)%"                                           Line 2 "CPU`t`t`t`t: " "$($Providerstatus.CPULoad)%"
                                        Line 2 "RAM`t`t: " "$($VDIHostStatus.MemLoad)%"                                           Line 2 "RAM`t`t`t`t: " "$($Providerstatus.MemLoad)%"
                                        Line 2 "Disk read time`t: " "$($VDIHostStatus.DiskRead)%"                                           Line 2 "Disk read time`t`t`t: " "$($Providerstatus.DiskRead)%"
                                        Line 2 "Disk write time`t: " "$($VDIHostStatus.DiskWrite)%"                                           Line 2 "Disk write time`t`t`t: " "$($Providerstatus.DiskWrite)%"
                                        Line 2 "Preferred PA`t: " $VDIHostStatus.PreferredPA                                           Line 2 "Preferred Connection Broker`t: " $Providerstatus.PreferredBroker
                                        Line 2 "Operating system: " $VDIHostStatus.ServerOS                                           Line 2 "Operating system`t`t: " $Providerstatus.ServerOS
                                        Line 2 "Agent version`t: " $VDIHostStatus.AgentVer                                           Line 2 "Agent version`t`t`t: " $Providerstatus.AgentVer
 
                                        $columnHeaders = @("Address",($Script:htmlsb),$VDIHost.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$Provider.Server,$htmlwhite)
 
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($VDIHostStatus.CPULoad)%",$htmlwhite)) <>                                         $rowdata += @(,("CPU",($Script:htmlsb),"$($Providerstatus.CPULoad)%",$htmlwhite))
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($VDIHostStatus.MemLoad)%",$htmlwhite))                                           $rowdata += @(,("RAM",($Script:htmlsb),"$($Providerstatus.MemLoad)%",$htmlwhite))
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($VDIHostStatus.DiskRead)%",$htmlwhite))                                           $rowdata += @(,("Disk read time",($Script:htmlsb),"$($Providerstatus.DiskRead)%",$htmlwhite))
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($VDIHostStatus.DiskWrite)%",$htmlwhite))                                           $rowdata += @(,("Disk write time",($Script:htmlsb),"$($Providerstatus.DiskWrite)%",$htmlwhite))
                                        $rowdata += @(,("Preferred PA",($Script:htmlsb),$VDIHostStatus.PreferredPA,$htmlwhite))                                           $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$Providerstatus.PreferredBroker,$htmlwhite))
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$VDIHostStatus.ServerOS,$htmlwhite))                                           $rowdata += @(,("Operating system",($Script:htmlsb),$Providerstatus.ServerOS,$htmlwhite))
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$VDIHostStatus.AgentVer,$htmlwhite))                                           $rowdata += @(,("Agent version",($Script:htmlsb),$Providerstatus.AgentVer,$htmlwhite))
 
                                        $columnWidths = @("200","275") <>                                         $columnWidths = @("200","350")
 
  <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Secure Gateways"
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Secure Gateways"
            }
            If($Text)
            {
                    Line 1 "Secure Gateways"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Secure Gateways"
            }
     
        $GWs = Get-RASGW -Siteid $Site.Id -EA 0 4> $Null           $SecureGateways = Get-RASGateway -Siteid $Site.Id -EA 0 4> $Null
 
                Unable to retrieve Gateways for Site $($Site.Name)` <>                 Unable to retrieve Secure Gateways for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $GWs) <>         ElseIf($? -and $Null -eq $SecureGateways)
 
                No Gateways retrieved for Site $($Site.Name).` <>                 No Secure Gateways retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No Gateways retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"
 
                        Line 0 "No Gateways retrieved for Site $($Site.Name)" <>                         Line 0 "No Secure Gateways retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No Gateways retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"
 
                If($MSWord -or $PDF) <>                 ForEach($SecureGateway in $SecureGateways)
 
                        WriteWordLine 2 0 "Gateways" <>  
                }    
                If($Text)    
                {    
                        Line 1 "Gateways"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "Gateways"    
                }    
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Site Gateways"    
                ForEach($GW in $GWs)    
                {    
                        $GWStatus = Get-RASGWStatus -Id $GW.Id -EA 0 4>$Null                           $SecureGatewayStatus = Get-RASGatewayStatus -Id $SecureGateway.Id -EA 0 4>$Null
 
                                Unable to retrieve Gateway Status for Gateway $($GW.Id)` <>                                 Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)`
 
                                        WriteWordLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"
 
                                        Line 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         Line 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Secure Gateway $($SecureGateway.Id)"
 
                        ElseIf($? -and $Null -eq $GWStatus) <>                         ElseIf($? -and $Null -eq $SecureGatewayStatus)
 
                                No Gateway Status retrieved for Gateway $($GW.Id)` <>                                 No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)`
 
                                        WriteWordLine 0 0 "No Gateway Status retrieved for Gateway $($GW.Id)" <>                                         WriteWordLine 0 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"
 
                                        Line 0 "No Gateway Status retrieved for Gateway $($GW.Id)" <>                                         Line 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"
 
                                        WriteHTMLLine 0 0 "No Gateway Status retrieved for Gateway $($GW.Id)" <>                                         WriteHTMLLine 0 0 "No Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)"
 
                                $Sessions = ($GWStatus.ActiveRDPSessions + $GWStatus.ActiveRDPSSLSessions) <>                                 $Sessions = ($SecureGatewayStatus.ActiveRDPSessions + $SecureGatewayStatus.ActiveRDPSSLSessions)
                                $GWStatusAgentState = GetRASStatus $GWStatus.AgentState                                   $SecureGatewayStatusAgentState = GetRASStatus $SecureGatewayStatus.AgentState
 
                                        $ScriptInformation.Add(@{Data = "Address"; Value = $GW.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Name"; Value = $SecureGateway.Server; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $GWStatusAgentState; }) > $Null                                           $ScriptInformation.Add(@{Data = "Status"; Value = $SecureGatewayStatusAgentState; }) > $Null
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($GWStatus.CPULoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "CPU"; Value = "$($SecureGatewayStatus.CPULoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($GWStatus.MemLoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "RAM"; Value = "$($SecureGatewayStatus.MemLoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($GWStatus.DiskRead)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($SecureGatewayStatus.DiskRead)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($GWStatus.DiskWrite)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($SecureGatewayStatus.DiskWrite)%"; }) > $Null
 
                                        $ScriptInformation.Add(@{Data = "Preferred PA"; Value = $GWStatus.PreferredPA; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $SecureGatewayStatus.PreferredBroker; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $GWStatus.ServerOS; }) > $Null                                           $ScriptInformation.Add(@{Data = "Operating system"; Value = $SecureGatewayStatus.ServerOS; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $GWStatus.AgentVer; }) > $Null                                           $ScriptInformation.Add(@{Data = "Agent version"; Value = $SecureGatewayStatus.AgentVer; }) > $Null
 
                                        $Table.Columns.Item(2).Width = 250; <>                                         $Table.Columns.Item(2).Width = 300;
 
                                        Line 2 "Address`t`t: " $GW.Server <>                                         Line 2 "Name`t`t`t`t: " $SecureGateway.Server
                                        Line 2 "Status`t`t: " $GWStatusAgentState                                           Line 2 "Status`t`t`t`t: " $SecureGatewayStatusAgentState
                                        Line 2 "CPU`t`t: " "$($GWStatus.CPULoad)%"                                           Line 2 "CPU`t`t`t`t: " "$($SecureGatewayStatus.CPULoad)%"
                                        Line 2 "RAM`t`t: " "$($GWStatus.MemLoad)%"                                           Line 2 "RAM`t`t`t`t: " "$($SecureGatewayStatus.MemLoad)%"
                                        Line 2 "Disk read time`t: " "$($GWStatus.DiskRead)%"                                           Line 2 "Disk read time`t`t`t: " "$($SecureGatewayStatus.DiskRead)%"
                                        Line 2 "Disk write time`t: " "$($GWStatus.DiskWrite)%"                                           Line 2 "Disk write time`t`t`t: " "$($SecureGatewayStatus.DiskWrite)%"
                                        Line 2 "Sessions`t: " $Sessions.ToString()                                           Line 2 "Sessions`t`t`t: " $Sessions.ToString()
                                        Line 2 "Preferred PA`t: " $GWStatus.PreferredPA                                           Line 2 "Preferred Connection Broker`t: " $SecureGatewayStatus.PreferredBroker
                                        Line 2 "Operating system: " $GWStatus.ServerOS                                           Line 2 "Operating system`t`t: " $SecureGatewayStatus.ServerOS
                                        Line 2 "Agent version`t: " $GWStatus.AgentVer                                           Line 2 "Agent version`t`t`t: " $SecureGatewayStatus.AgentVer
 
                                        $columnHeaders = @("Address",($Script:htmlsb),$GW.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$SecureGateway.Server,$htmlwhite)
                                        $rowdata += @(,("Status",($Script:htmlsb),$GWStatusAgentState.ToString(),$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$SecureGatewayStatusAgentState.ToString(),$htmlwhite))
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($GWStatus.CPULoad)%",$htmlwhite))                                           $rowdata += @(,("CPU",($Script:htmlsb),"$($SecureGatewayStatus.CPULoad)%",$htmlwhite))
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($GWStatus.MemLoad)%",$htmlwhite))                                           $rowdata += @(,("RAM",($Script:htmlsb),"$($SecureGatewayStatus.MemLoad)%",$htmlwhite))
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($GWStatus.DiskRead)%",$htmlwhite))                                           $rowdata += @(,("Disk read time",($Script:htmlsb),"$($SecureGatewayStatus.DiskRead)%",$htmlwhite))
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($GWStatus.DiskWrite)%",$htmlwhite))                                           $rowdata += @(,("Disk write time",($Script:htmlsb),"$($SecureGatewayStatus.DiskWrite)%",$htmlwhite))
 
                                        $rowdata += @(,("Preferred PA",($Script:htmlsb),$GWStatus.PreferredPA,$htmlwhite)) <>                                         $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$SecureGatewayStatus.PreferredBroker,$htmlwhite))
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$GWStatus.ServerOS,$htmlwhite))                                           $rowdata += @(,("Operating system",($Script:htmlsb),$SecureGatewayStatus.ServerOS,$htmlwhite))
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$GWStatus.AgentVer,$htmlwhite))                                           $rowdata += @(,("Agent version",($Script:htmlsb),$SecureGatewayStatus.AgentVer,$htmlwhite))
 
                                        $columnWidths = @("200","275") <>                                         $columnWidths = @("200","350")
 
  <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Connection Brokers"
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Connection Brokers"
            }
            If($Text)
            {
                    Line 1 "Connection Brokers"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Connection Brokers"
            }
     
        $PAs = Get-RASPA -Siteid $Site.Id -EA 0 4> $Null           $ConnectionBrokers = Get-RASBroker -Siteid $Site.Id -EA 0 4> $Null
 
                Unable to retrieve Publishing Agents for Site $($Site.Name)` <>                 Unable to retrieve Connection Brokers for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $PAs) <>         ElseIf($? -and $Null -eq $ConnectionBrokers)
 
                No Publishing Agents retrieved for Site $($Site.Name).` <>                 No Connection Brokers retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"
 
                        Line 0 "No Publishing Agents retrieved for Site $($Site.Name)" <>                         Line 0 "No Connection Brokers retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"
 
                If($MSWord -or $PDF) <>                 ForEach($ConnectionBroker in $ConnectionBrokers)
 
                        WriteWordLine 2 0 "Publishing Agents" <>  
                }    
                If($Text)    
                {    
                        Line 1 "Publishing Agents"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "Publishing Agents"    
                }    
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing Agents"    
                ForEach($PA in $PAs)    
                {    
                        $PAStatus = Get-RASPAStatus -Id $PA.Id -EA 0 4>$Null                           $ConnectionBrokerStatus = Get-RASBrokerStatus -Id $ConnectionBroker.Id -EA 0 4>$Null
 
                                Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)` <>                                 Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)`
 
                                        WriteWordLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         WriteWordLine 0 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"
 
                                        Line 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         Line 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"
 
                                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents Status for Publishing Agents $($PA.Id)" <>                                         WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers Status for Connection Brokers $($ConnectionBroker.Id)"
 
                        ElseIf($? -and $Null -eq $PAStatus) <>                         ElseIf($? -and $Null -eq $ConnectionBrokerStatus)
 
                                No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)` <>                                 No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)`
 
                                        WriteWordLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         WriteWordLine 0 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"
 
                                        Line 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         Line 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"
 
                                        WriteHTMLLine 0 0 "No Publishing Agents Status retrieved for Publishing Agents $($PA.Id)" <>                                         WriteHTMLLine 0 0 "No Connection Brokers Status retrieved for Connection Brokers $($ConnectionBroker.Id)"
 
  <>                                 If($ConnectionBroker.Priority -eq 0)
                                    {
                                            $ConnectionBrokerPriority = "Primary"
                                    }
                                    Else
                                    {
                                            $ConnectionBrokerPriority = "Secondary"
                                    }
                                    
                                $PAStatusAgentState = GetRASStatus $PAStatus.AgentState                                   $ConnectionBrokerStatusAgentState = GetRASStatus $ConnectionBrokerStatus.AgentState
 
                                        $ScriptInformation.Add(@{Data = "Address"; Value = $PA.Server; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Name"; Value = $ConnectionBroker.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Priority"; Value = $ConnectionBrokerPriority; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $PAStatusAgentState; }) > $Null                                           $ScriptInformation.Add(@{Data = "Status"; Value = $ConnectionBrokerStatusAgentState; }) > $Null
                                        $ScriptInformation.Add(@{Data = "CPU"; Value = "$($PAStatus.CPULoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "CPU"; Value = "$($ConnectionBrokerStatus.CPULoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "RAM"; Value = "$($PAStatus.MemLoad)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "RAM"; Value = "$($ConnectionBrokerStatus.MemLoad)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($PAStatus.DiskRead)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk read time"; Value = "$($ConnectionBrokerStatus.DiskRead)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($PAStatus.DiskWrite)%"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disk write time"; Value = "$($ConnectionBrokerStatus.DiskWrite)%"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Operating system"; Value = $PAStatus.ServerOS; }) > $Null                                           $ScriptInformation.Add(@{Data = "Operating system"; Value = $ConnectionBrokerStatus.ServerOS; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Agent version"; Value = $PAStatus.AgentVer; }) > $Null                                           $ScriptInformation.Add(@{Data = "Agent version"; Value = $ConnectionBrokerStatus.AgentVer; }) > $Null
 
                                        $Table.Columns.Item(2).Width = 250; <>                                         $Table.Columns.Item(2).Width = 300;
 
                                        Line 2 "Address`t`t: " $PA.Server <>                                         Line 2 "Name`t`t: " $ConnectionBroker.Server
                                            Line 2 "Priority`t: " $ConnectionBrokerPriority
                                        Line 2 "Status`t`t: " $PAStatusAgentState                                           Line 2 "Status`t`t: " $ConnectionBrokerStatusAgentState
                                        Line 2 "CPU`t`t: " "$($PAStatus.CPULoad)%"                                           Line 2 "CPU`t`t: " "$($ConnectionBrokerStatus.CPULoad)%"
                                        Line 2 "RAM`t`t: " "$($PAStatus.MemLoad)%"                                           Line 2 "RAM`t`t: " "$($ConnectionBrokerStatus.MemLoad)%"
                                        Line 2 "Disk read time`t: " "$($PAStatus.DiskRead)%"                                           Line 2 "Disk read time`t: " "$($ConnectionBrokerStatus.DiskRead)%"
                                        Line 2 "Disk write time`t: " "$($PAStatus.DiskWrite)%"                                           Line 2 "Disk write time`t: " "$($ConnectionBrokerStatus.DiskWrite)%"
                                        Line 2 "Operating system: " $PAStatus.ServerOS                                           Line 2 "Operating system: " $ConnectionBrokerStatus.ServerOS
                                        Line 2 "Agent version`t: " $PAStatus.AgentVer                                           Line 2 "Agent version`t: " $ConnectionBrokerStatus.AgentVer
 
                                        $columnHeaders = @("Address",($Script:htmlsb),$PA.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$ConnectionBroker.Server,$htmlwhite)
                                            $rowdata += @(,("Priority",($Script:htmlsb),$ConnectionBrokerPriority,$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$PAStatusAgentState.ToString(),$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$ConnectionBrokerStatusAgentState.ToString(),$htmlwhite))
                                        $rowdata += @(,("CPU",($Script:htmlsb),"$($PAStatus.CPULoad)%",$htmlwhite))                                           $rowdata += @(,("CPU",($Script:htmlsb),"$($ConnectionBrokerStatus.CPULoad)%",$htmlwhite))
                                        $rowdata += @(,("RAM",($Script:htmlsb),"$($PAStatus.MemLoad)%",$htmlwhite))                                           $rowdata += @(,("RAM",($Script:htmlsb),"$($ConnectionBrokerStatus.MemLoad)%",$htmlwhite))
                                        $rowdata += @(,("Disk read time",($Script:htmlsb),"$($PAStatus.DiskRead)%",$htmlwhite))                                           $rowdata += @(,("Disk read time",($Script:htmlsb),"$($ConnectionBrokerStatus.DiskRead)%",$htmlwhite))
                                        $rowdata += @(,("Disk write time",($Script:htmlsb),"$($PAStatus.DiskWrite)%",$htmlwhite))                                           $rowdata += @(,("Disk write time",($Script:htmlsb),"$($ConnectionBrokerStatus.DiskWrite)%",$htmlwhite))
                                        $rowdata += @(,("Operating system",($Script:htmlsb),$PAStatus.ServerOS,$htmlwhite))                                           $rowdata += @(,("Operating system",($Script:htmlsb),$ConnectionBrokerStatus.ServerOS,$htmlwhite))
                                        $rowdata += @(,("Agent version",($Script:htmlsb),$PAStatus.AgentVer,$htmlwhite))                                           $rowdata += @(,("Agent version",($Script:htmlsb),$ConnectionBrokerStatus.AgentVer,$htmlwhite))
 
                                        $columnWidths = @("200","275") <>                                         $columnWidths = @("200","350")
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Hosts" <>         Write-Verbose "$(Get-Date -Format G): Output RD Session Hosts"
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "RD Session Hosts"
            }
            If($Text)
            {
                    Line 1 "RD Session Hosts"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "RD Session Hosts"
            }
     
 
                If($MSWord -or $PDF) +-  
                {    
                        WriteWordLine 2 0 "RD Session Hosts"    
                }    
                If($Text)    
                {    
                        Line 1 "RD Session Hosts"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "RD Session Hosts"    
                }    
     
 
                        Write-Verbose "$(Get-Date -Format G): `t`t`tOutput RD Session Host $($RDSHost.Server)" <>                         Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host $($RDSHost.Server)"
 
                                $Status      = "N/A" +-  
 
                                        $UPDDefault = (Get-RASRDSDefaultSettings -SiteId $Site.Id -Ea 0).UPDMode <>                                         $UPDDefault = (Get-RASRDSDefaultSettings -SiteId $Site.Id -Ea 0 4>$Null).UPDMode
 
                                Line 4 "Enable server in site`t`t`t`t`t: " $RDSHost.Enabled.ToString() <>                                 Line 4 "Enable server in site`t: " $RDSHost.Enabled.ToString()
                                Line 4 "Server`t`t`t`t`t`t`t: " $RDSHost.Server                                   Line 4 "Server`t`t`t: " $RDSHost.Server
                                Line 4 "Description`t`t`t`t`t`t: " $RDSHost.Description                                   Line 4 "Description`t`t: " $RDSHost.Description
                                Line 4 "Direct Address`t`t`t`t`t`t: " $RDSHost.DirectAddress                                   Line 4 "Direct Address`t`t: " $RDSHost.DirectAddress
 
                                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                                     Break}
                                                                "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                                                   "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                                     Break}
                                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                                     $ReplaceRegisteredApplication = "True";
                                                                                                                                     Break}
                                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($GroupDefaults.AllowURLAndMailRedirection)"; Break}                                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($GroupDefaults.AllowURLAndMailRedirection)";
                                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                                     Break}
 
                                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                                                    $RDSAllowDragAndDrop = "True";
                                                                    Break}
                                                                "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                                                    $RDSAllowDragAndDrop = "False";
                                                                    Break}
                                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                                                    $RDSAllowDragAndDrop = "True";
                                                                    Break}
                                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                                                    $RDSAllowDragAndDrop = "True";
                                                                    Break}
                                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($GroupDefaults.DragAndDropMode)"; Break}                                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($GroupDefaults.DragAndDropMode)";
                                                                    $RDSAllowDragAndDrop = "False";
                                                                    Break}
 
                                                        If($GroupDefaults.PreferredPAId -eq 0) <>                                                         If($GroupDefaults.PreferredBrokerId -eq 0)
 
                                                                $RDSPreferredPublishingAgent = (Get-RASPA -Id $GroupDefaults.PreferredPAId -EA 0 4>$Null).Server <>                                                                 $RDSPreferredPublishingAgent = (Get-RASBroker -Id $GroupDefaults.PreferredBrokerId -EA 0 4>$Null).Server
 
                                                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                                                             Break}
                                                                        "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                                                           "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                                                             Break}
                                                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                                             $ReplaceRegisteredApplication = "True";
                                                                                                                                             Break}
                                                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)"; Break}                                                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)";
                                                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                                                             Break}
 
                                                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                                                            $RDSAllowDragAndDrop = "True";
                                                                            Break}
                                                                        "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                                                           "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                                                            $RDSAllowDragAndDrop = "False";
                                                                            Break}
                                                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                                                            $RDSAllowDragAndDrop = "True";
                                                                            Break}
                                                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                                                            $RDSAllowDragAndDrop = "True";
                                                                            Break}
                                                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)"; Break}                                                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)";
                                                                            $RDSAllowDragAndDrop = "False";
                                                                            Break}
 
                                                                If($RDSDefaults.PreferredPAId -eq 0) <>                                                                 If($RDSDefaults.PreferredBrokerId -eq 0)
 
                                                                        $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSDefaults.PreferredPAId -EA 0 4>$Null).Server <>                                                                         $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSDefaults.PreferredBrokerId -EA 0 4>$Null).Server
 
  -+                                                                 $ReplaceRegisteredApplication          = "False"
 
  -+                                                                 $RDSAllowDragAndDrop                   = "Enabled"
 
                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
                                                "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                                   "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                     $ReplaceRegisteredApplication = "True";
                                                                                                                     Break}
                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)"; Break}                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
 
                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                                    $RDSAllowDragAndDrop = "False";
                                                    Break}
                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)"; Break}                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)";
                                                    $RDSAllowDragAndDrop = "False";
                                                    Break}
 
                                        If($RDSHost.PreferredPAId -eq 0) <>                                         If($RDSHost.PreferredBrokerId -eq 0)
 
                                                $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSHost.PreferredPAId -EA 0 4>$Null).Server <>                                                 $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSHost.PreferredBrokerId -EA 0 4>$Null).Server
 
                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                        "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                           "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "True";
                                                                                                             Break}
                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)"; Break}                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSHost.AllowURLAndMailRedirection)";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
 
                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                           "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                            $RDSAllowDragAndDrop = "False";
                                            Break}
                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)"; Break}                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSHost.DragAndDropMode)";
                                            $RDSAllowDragAndDrop = "False";
                                            Break}
 
                                If($RDSHost.PreferredPAId -eq 0) <>                                 If($RDSHost.PreferredBrokerId -eq 0)
 
                                        $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSHost.PreferredPAId -EA 0 4>$Null).Server <>                                         $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSHost.PreferredBrokerId -EA 0 4>$Null).Server
 
  <>                                 $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Disconnect active session after"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Logoff disconnected session after"; Value = $RDSPublishingSessionResetTime; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Other settings"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "Port"; Value = $RDSPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Port"; Value = $RDSPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Max Sessions"; Value = $RDSMaxSessions; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Max Sessions"; Value = $RDSMaxSessions; }) > $Null
                                $ScriptInformation.Add(@{Data = "Publishing Session Disconnect Timeout"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Publishing Session Reset Timeout"; Value = $RDSPublishingSessionResetTime; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Preferred Connection Broker"; Value = $RDSPreferredPublishingAgent; }) > $Null
 
  <>                                 $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null
                                $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null
                                $ScriptInformation.Add(@{Data = "Drag and drop"; Value = $RDSDragAndDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $RDSAllowDragandDrop; }) > $Null
                                $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $RDSPreferredPublishingAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSDragAndDrop; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null
                                $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSFileTransferMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Direction"; Value = $RDSFileTransferMode; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Location"; Value = $RDSFileTransferLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Location"; Value = $RDSFileTransferLocation; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null
 
                                Line 4 "Inherit default settings`t`t`t`t: " $RDSHost.InheritDefaultAgentSettings.ToString() <>                                 Line 4 "Inherit default settings`t`t`t`t`t: " $RDSHost.InheritDefaultAgentSettings.ToString()
                                    Line 4 "Application session lingering"
                                    Line 5 "Disconnect active session after`t`t`t`t: " $RDSPublishingSessionDisconnectTimeout
                                    Line 5 "Logoff disconnected session after`t`t`t: " $RDSPublishingSessionResetTime
                                    Line 4 "Other settings"
                                Line 4 "Port`t`t`t`t`t`t`t: " $RDSPort                                   Line 5 "Port`t`t`t`t`t`t`t: " $RDSPort
                                Line 4 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions                                   Line 5 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions
                                Line 4 "Publishing Session Disconnect Timeout`t`t`t: " $RDSPublishingSessionDisconnectTimeout    
                                Line 4 "Publishing Session Reset Timeout`t`t`t: " $RDSPublishingSessionResetTime                                   Line 5 "Preferred Connection Broker`t`t`t`t: " $RDSPreferredPublishingAgent
                                Line 4 "Allow Client URL/Mail Redirection`t`t`t: " $RDSAllowClientURLMailRedirection                                   Line 4 "Allow Client URL/Mail Redirection`t`t`t`t: " $RDSAllowClientURLMailRedirection
                                    Line 5 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication
                                Line 4 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject                                   Line 5 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject
                                Line 4 "Drag and drop`t`t`t`t`t`t: " $RDSDragAndDrop                                   Line 4 "Enable Drag and drop`t`t`t`t`t`t: " $RDSAllowDragandDrop
                                Line 4 "Preferred Publishing Agent`t`t`t`t: " $RDSPreferredPublishingAgent                                   Line 5 "Direction`t`t`t`t`t`t: " $RDSDragAndDrop
                                Line 4 "Allow 2xRemoteExec to send command to the client`t: " $RDSAllowRemoteExec                                   Line 4 "Allow 2xRemoteExec to send command to the client`t`t: " $RDSAllowRemoteExec
                                Line 4 "Use RemoteApp if available`t`t`t`t: " $RDSUseRemoteApps                                   Line 4 "Use RemoteApp if available`t`t`t`t`t: " $RDSUseRemoteApps
                                Line 4 "Enable applications monitoring`t`t`t`t: " $RDSEnableAppMonitoring                                   Line 4 "Enable applications monitoring`t`t`t`t`t: " $RDSEnableAppMonitoring
                                Line 4 "Allow file transfer command (HTML5 and Chrome clients)`t: " $RDSAllowFileTransfer                                   Line 4 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $RDSAllowFileTransfer
                                Line 4 "Configure File Transfer"                                   Line 5 "Configure File Transfer"
                                Line 5 "Direction`t`t`t: " $RDSFileTransferMode                                   Line 6 "Direction`t`t`t: " $RDSFileTransferMode
                                Line 5 "Location`t`t`t: " $RDSFileTransferLocation                                   Line 6 "Location`t`t`t: " $RDSFileTransferLocation
                                Line 5 "Do not allow to change location`t: " $RDSFileTransferChangeLocation                                   Line 6 "Do not allow to change location : " $RDSFileTransferChangeLocation
                                Line 4 "Enable drive redirection cache`t`t`t`t: " $RDSEnableDriveRedirectionCache                                   Line 4 "Enable drive redirection cache`t`t`t`t`t: " $RDSEnableDriveRedirectionCache
 
  <>                                 $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Disconnect active session after",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))
                                    $rowdata += @(,("     Logoff disconnected session after",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))
                                    $rowdata += @(,("Other settings",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("Port",($Script:htmlsb),$RDSPort,$htmlwhite))                                   $rowdata += @(,("     Port",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))                                   $rowdata += @(,("     Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))
                                $rowdata += @(,("Publishing Session Disconnect Timeout",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))    
                                $rowdata += @(,("Publishing Session Reset Timeout",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))                                   $rowdata += @(,("     Preferred Connection Broker",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))
 
  <>                                 $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite))
                                $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))                                   $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))
                                $rowdata += @(,("Drag and drop",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))                                   $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$RDSAllowDragandDrop,$htmlwhite))
                                $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))                                   $rowdata += @(,("     Direction",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))
 
                                $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite)) <>                                 $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite))
                                $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("     Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))                                   $rowdata += @(,("          Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))
                                $rowdata += @(,("     Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))                                   $rowdata += @(,("          Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))
                                $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))                                   $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))
 
                        #Desktop Access <>                         #Optimization
 
                                WriteWordLine 4 0 "Desktop access" <>                                 WriteWordLine 4 0 "Optimization"
 
                                Line 3 "Desktop access" <>                                 Line 3 "Optimization"
 
                         <>  
                            <#
                            Get-RASImageOptimization -Id 1 -ObjType RDS
     
                            EnableOptimization            : True
                            OptimizationType              : Automatic
                            WindowsDefenderATP            : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsDefenderATP
                            WindowsComponents             : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsComponents
                            WindowsDefenderATPEnabled     : True
                            WindowsComponentsEnabled      : True
                            WindowsServicesEnabled        : True
                            WindowsScheduledTasksEnabled  : True
                            WindowsAdvancedOptionsEnabled : True
                            NetworkPerformanceEnabled     : True
                            RegistryEnabled               : True
                            VisualEffectsEnabled          : True
                            DiskCleanupEnabled            : True
                            CustomScriptEnabled           : False
                            WindowsServices               : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsServices
                            WindowsAdvancedOptions        : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsAdvancedOptions
                            NetworkPerformance            : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.NetworkPerformance
                            CustomScript                  : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.CustomScript
                            DiskCleanup                   : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.DiskCleanup
                            VisualEffects                 : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.VisualEffects
                            WindowsScheduledTasks         : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.WindowsScheduledTasks
                            Registry                      : RASAdminEngine.Core.OutputModels.ImagesOptimization.Categories.Registries
                            #>
     
                        If($RDSHost.InheritDefaultDesktopAccessSettings)                           If($RDSHost.InheritDefaultOptimizationSettings)
 
                                $Results = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null <>                                 $RDSGroup = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null
 
                                If($? -and $Null -ne $Results) <>                                 If($? -and $Null -ne $RDSGroup)
 
                                        If($Results.RDSIds -Contains $RDSHost.Id ) <>                                         If($RDSGroup.RDSIds -Contains $RDSHost.Id )
 
                                                If($Results.InheritDefaultDesktopAccessSettings -eq $False) <>                                                 If($RDSGroup.InheritDefaultOptimizationSettings -eq $False)
 
                                                        $GroupDefaults = $Results.RDSDefSettings <>                                                         $OPTEnableOptimization            = $RDSGroup.Optimization.EnableOptimization.ToString()
                                                            $OPTOptimizationType              = $RDSGroup.Optimization.OptimizationType.ToString()
                                                        $RDSRestrictDesktopAccess = $GroupDefaults.RestrictDesktopAccess.ToString()                                                           $OPTWindowsDefenderATPEnabled     = $RDSGroup.Optimization.WindowsDefenderATPEnabled.ToString()    
                                                        $RDSRestrictedUsers       = @()                                                           $OPTWindowsComponentsEnabled      = $RDSGroup.Optimization.WindowsComponentsEnabled.ToString()
                                                                                                                  $OPTWindowsServicesEnabled        = $RDSGroup.Optimization.WindowsServicesEnabled.ToString()
                                                        ForEach($User in $GroupDefaults.RestrictedUsers)                                                           $OPTWinodwsScheduledTasksEnabled  = $RDSGroup.Optimization.WindowsScheduledTasksEnabled.ToString()
                                                        {                                                           $OPTWindowsAdvancedOptionsEnabled = $RDSGroup.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                                            $OPTNetworkPerformanceEnabled     = $RDSGroup.Optimization.NetworkPerformanceEnabled.ToString()
                                                                $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)                                                           $OPTRegistryEnabled               = $RDSGroup.Optimization.RegistryEnabled.ToString()
                                                                $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])                                                           $OPTVisualEffectsEnabled          = $RDSGroup.Optimization.VisualEffectsEnabled.ToString()   
                                                                                                                          $OPTDiskCleanupEnabled            = $RDSGroup.Optimization.DiskCleanupEnabled.ToString()
                                                                $RDSRestrictedUsers += $objUser.Value                                                           $OPTCustomScriptEnabled           = $RDSGroup.Optimization.CustomScriptEnabled.ToString()
                                                        }    
 
                                                                $RDSRestrictDesktopAccess = $RDSDefaults.RestrictDesktopAccess.ToString() <>                                                                 $OPTEnableOptimization            = $RDSDefaults.Optimization.EnableOptimization.ToString()
                                                                $RDSRestrictedUsers       = @()                                                                   $OPTOptimizationType              = $RDSDefaults.Optimization.OptimizationType.ToString()
                                                                                                                                  $OPTWindowsDefenderATPEnabled     = $RDSDefaults.Optimization.WindowsDefenderATPEnabled.ToString()    
                                                                ForEach($User in $RDSDefaults.RestrictedUsers)                                                                   $OPTWindowsComponentsEnabled      = $RDSDefaults.Optimization.WindowsComponentsEnabled.ToString()
                                                                {                                                                   $OPTWindowsServicesEnabled        = $RDSDefaults.Optimization.WindowsServicesEnabled.ToString()
                                                                    $OPTWinodwsScheduledTasksEnabled  = $RDSDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()
                                                                    $OPTWindowsAdvancedOptionsEnabled = $RDSDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                                                    $OPTNetworkPerformanceEnabled     = $RDSDefaults.Optimization.NetworkPerformanceEnabled.ToString()
                                                                        $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)                                                                   $OPTRegistryEnabled               = $RDSDefaults.Optimization.RegistryEnabled.ToString()
                                                                    $OPTVisualEffectsEnabled          = $RDSDefaults.Optimization.VisualEffectsEnabled.ToString()   
                                                                    $OPTDiskCleanupEnabled            = $RDSDefaults.Optimization.DiskCleanupEnabled.ToString()
                                                                        $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])                                                                   $OPTCustomScriptEnabled           = $RDSDefaults.Optimization.CustomScriptEnabled.ToString()
                                                                            
                                                                        $RDSRestrictedUsers += $objUser.Value    
                                                                }    
 
  <>                                                                 $OPTEnableOptimization            = "False"
                                                                    $OPTOptimizationType              = ""
                                                                    $OPTWindowsDefenderATPEnabled     = "False"
                                                                    $OPTWindowsComponentsEnabled      = "False"
                                                                    $OPTWindowsServicesEnabled        = "False"
                                                                    $OPTWinodwsScheduledTasksEnabled  = "False"
                                                                    $OPTWindowsAdvancedOptionsEnabled = "False"
                                                                    $OPTNetworkPerformanceEnabled     = "False"
                                                                    $OPTRegistryEnabled               = "False"
                                                                    $OPTVisualEffectsEnabled          = "False"
                                                                    $OPTDiskCleanupEnabled            = "False"
                                                                $RDSRestrictDesktopAccess = "False"                                                                   $OPTCustomScriptEnabled           = "False"
                                                                $RDSRestrictedUsers       = @()    
 
                                        $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString() +-  
                                        $RDSRestrictedUsers       = @()    
 
                                        ForEach($User in $RDSHost.RestrictedUsers) <>                                         $OPTEnableOptimization            = $RDSHost.Optimization.EnableOptimization.ToString()
                                        {                                           $OPTOptimizationType              = $RDSHost.Optimization.OptimizationType.ToString()
                                            $OPTWindowsDefenderATPEnabled     = $RDSHost.Optimization.WindowsDefenderATPEnabled.ToString()    
                                            $OPTWindowsComponentsEnabled      = $RDSHost.Optimization.WindowsComponentsEnabled.ToString()
                                            $OPTWindowsServicesEnabled        = $RDSHost.Optimization.WindowsServicesEnabled.ToString()
                                            $OPTWinodwsScheduledTasksEnabled  = $RDSHost.Optimization.WindowsScheduledTasksEnabled.ToString()
                                            $OPTWindowsAdvancedOptionsEnabled = $RDSHost.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                            $OPTNetworkPerformanceEnabled     = $RDSHost.Optimization.NetworkPerformanceEnabled.ToString()
                                                $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)                                           $OPTRegistryEnabled               = $RDSHost.Optimization.RegistryEnabled.ToString()
                                            $OPTVisualEffectsEnabled          = $RDSHost.Optimization.VisualEffectsEnabled.ToString()   
                                            $OPTDiskCleanupEnabled            = $RDSHost.Optimization.DiskCleanupEnabled.ToString()
                                                $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])                                           $OPTCustomScriptEnabled           = $RDSHost.Optimization.CustomScriptEnabled.ToString()
                                                    
                                                $RDSRestrictedUsers += $objUser.Value    
                                        }    
 
                                $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString() +-  
                                $RDSRestrictedUsers       = @()    
 
                                ForEach($User in $RDSHost.RestrictedUsers) <>                                 $OPTEnableOptimization            = $RDSHost.Optimization.EnableOptimization.ToString()
                                {                                   $OPTOptimizationType              = $RDSHost.Optimization.OptimizationType.ToString()
                                    $OPTWindowsDefenderATPEnabled     = $RDSHost.Optimization.WindowsDefenderATPEnabled.ToString()    
                                    $OPTWindowsComponentsEnabled      = $RDSHost.Optimization.WindowsComponentsEnabled.ToString()
                                    $OPTWindowsServicesEnabled        = $RDSHost.Optimization.WindowsServicesEnabled.ToString()
                                    $OPTWinodwsScheduledTasksEnabled  = $RDSHost.Optimization.WindowsScheduledTasksEnabled.ToString()
                                    $OPTWindowsAdvancedOptionsEnabled = $RDSHost.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                    $OPTNetworkPerformanceEnabled     = $RDSHost.Optimization.NetworkPerformanceEnabled.ToString()
                                        $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)                                   $OPTRegistryEnabled               = $RDSHost.Optimization.RegistryEnabled.ToString()
                                    $OPTVisualEffectsEnabled          = $RDSHost.Optimization.VisualEffectsEnabled.ToString()   
                                    $OPTDiskCleanupEnabled            = $RDSHost.Optimization.DiskCleanupEnabled.ToString()
                                        $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])                                   $OPTCustomScriptEnabled           = $RDSHost.Optimization.CustomScriptEnabled.ToString()
                                            
                                        $RDSRestrictedUsers += $objUser.Value    
                                }                           }
                        }    
                                    
 
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultDesktopAccessSettings.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultUserProfileSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 250;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null
     
                                            If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                            {
                                                    $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null
                                            }
                                            Else
                                            {
                                $ScriptInformation.Add(@{Data = "Restrict direct desktop access to the following users"; Value = $RDSRestrictDesktopAccess; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                                                  
                                $cnt = -1                                                   $cnt = -1
                                ForEach($Item in $RDSRestrictedUsers)                                                   ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)
                                {                                                   {
                                        $cnt++                                                           $cnt++
                                        If($cnt -eq 0)                                                           If($cnt -eq 0)
                                        {                                                           {
                                                                    $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                $ScriptInformation.Add(@{Data = "Users"; Value = $Item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                        }                                                           }
                                                    }
     
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null
                                                            }
                                        Else                                                           Else
                                        {                                                           {
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                        }                                                           }
                                }                                                   }
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                            }
                                                    }
                                            }
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 250; <>                                         $Table.Columns.Item(1).Width = 250;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
     
                                    WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)
                                            {
                                                            If($Null -eq $item.DisplayName)
                                                            {
                                                                    $DisplayName = ""
                                                            }
                                                            Else
                                                            {
                                                                    $DisplayName = $item.DisplayName
                                                            }
                                                            If($Null -eq $item.ComponentName)
                                                            {
                                                                    $ComponentName = ""
                                                            }
                                                            Else
                                                            {
                                                                    $ComponentName = $item.ComponentName
                                                            }
                                                    $OptimizationTable += @{
                                                            DisplayName = $DisplayName
                                                            ComponentName = $ComponentName
                                                    }
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns DisplayName, ComponentName `
                                                    -Headers "Display name", "Component" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 200;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
     
                                    WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)
                                            {
                                                            If($Null -eq $item.DisplayName)
                                                            {
                                                                    $DisplayName = ""
                                                            }
                                                            Else
                                                            {
                                                                    $DisplayName = $item.DisplayName
                                                            }
                                                            If($Null -eq $item.ServiceName)
                                                            {
                                                                    $Service = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Service = $item.ServiceName
                                                            }
                                                            If($Null -eq $item.Aliases)
                                                            {
                                                                    $Aliases = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Aliases = $item.Aliases
                                                            }
                                                    $OptimizationTable += @{
                                                            DisplayName = $DisplayName
                                                            Service     = $Service
                                                            Aliases     = $Aliases
                                                    }
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns DisplayName, Service, Aliases `
                                                    -Headers "Display name", "Service", "Aliases" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 100;
                                                    $Table.Columns.Item(3).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                            {
                                                            If($Null -eq $item.Task)
                                                            {
                                                                    $Task = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Task = $item.Task
                                                            }
                                                            If($Null -eq $item.Type)
                                                            {
                                                                    $Type = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Type = $item.Type.ToString()
                                                            }
                                                            If($Null -eq $item.Location)
                                                            {
                                                                    $Location = ""
                                                            }
                                                            Else
                                                            {
                                                                    $Location = $item.Location
                                                            }
                                                    $OptimizationTable += @{
                                                            Task     = $Task
                                                            Type     = $Type
                                                            Location = $Location
                                                    }
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Task, Type, Location `
                                                    -Headers "Task", "Type", "Location" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 250;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Disable Hibernate"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Telemetry collection"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable System Restore"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable error reporting to send additional data"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Tiles"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Cortana digital assistant"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Turn off Microsoft consumer experience"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Do not show Windows tips"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Remove Common program groups from the Start Menu"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Partial Start Menu layout"
                                                    Enabled = $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()
                                                    Value   = $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled, Value `
                                                    -Headers "Setting", "Enabled", "Value" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 275;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 175;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTNetworkPerformanceEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "FileInfoCacheEntriesMax"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()
                                                    Value   = $RDSHost.Optimization.NetworkPerformance.FileInfoCache
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "DirectoryCacheEntriesMax"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()
                                                    Value   = $RDSHost.Optimization.NetworkPerformance.DirCacheMax
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "FileNotFoundCacheEntriesMax"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()
                                                    Value   = $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "DormantFileLimit"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()
                                                    Value   = $RDSHost.Optimization.NetworkPerformance.DormantFileLimit
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable TCP/IP Task Offload"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable IPv6 Components"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable IPv6 to IPv4"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disables isatap for IPv6"
                                                    Enabled = $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString()
                                                    Value   = ""
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled, Value `
                                                    -Headers "Setting", "Enabled", "Value" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 150;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
     
                                    WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled
                                    If($OPTRegistryEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
     
                                            ForEach($item in $RDSHost.Optimization.Registry.RegistryList)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                            }
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 125;
                                            $Table.Columns.Item(2).Width = 375;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    
                                    WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Animate controls and elements inside windows"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Animate windows when minimizing and maximizing"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Animations in the taskbar"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Enable Peek"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.EnablePeek.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Fade or slide menus into view"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Fade or slide Tooltips into view"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Fade out menu items after clicking"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Save taskbar thumbnail previews"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show shadows under mouse pointer"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show shadows under windows"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show thumbnails instead of icons"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show translucent selection rectangle"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show window contents while dragging"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Slide open combo boxes"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Smooth edges of screen fonts"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Smooth-scroll list boxes"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Use drop shadows for icon labels on the desktop"
                                                    Enabled = $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString()
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled `
                                                    -Headers "Setting", "Enabled" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 250;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Clean up redundant system files"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Clean up the WinSxS Folder"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Clean up temporary files and logs"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Remove OneDrive"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Delete users' profiles"
                                                    Enabled = $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString()
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled `
                                                    -Headers "Setting", "Enabled" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 175;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
     
                                    WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Command"; Value = $RDSHost.Optimization.CustomScript.Command; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Arguments"; Value = $RDSHost.Optimization.CustomScript.Arguments; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $RDSHost.Optimization.CustomScript.InitDir; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Username"; Value = $RDSHost.Optimization.CustomScript.User; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 100;
                                            $Table.Columns.Item(2).Width = 200;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                            }
                            If($Text)
                            {
                                    Line 4 "Inherit default settings`t: " $RDSHost.InheritDefaultOptimizationSettings.ToString()
                                    Line 4 "Enable optimization`t`t: " $OPTEnableOptimization
                                    Line 4 "Optimization type`t`t: " $OPTOptimizationType
                                    Line 4 "Category"
                                    
                                    Line 5 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            Line 6 "Windows Defender ATP Optimizations"
                                            <#
                                                    WinDefATPTurnOffOn        : TurnOnWindowsDefenderATP
                                                    DisableRealTimeProtection : False
                                                    ExcludeFolders            : {%ProgramData%\Parallels\RASLogs\, %ProgramFiles(x86)%\Parallels\,
                                                                                                            %ProgramFiles%\Parallels\, %WINDOWS%\system32\config\...}
                                                    ExcludeProcesses          : {csrss.exe, winlogon.exe, rdpclip.exe, rdpinit.exe...}
                                                    ExcludeExtension          : {.vhd, .vhdx}                                       
                                            #>
                                            If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                            {
                                                    Line 7 "Turn off Windows Defender ATP (I use my own ATP solution)"
                                            }
                                            Else
                                            {
                                                    Line 7 "Turn on Windows Defender ATP and set process and folder exclusions"
                                                    Line 7 "Disable real-time protection: " $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()
                                                    Line 0 ""
                                                    Line 7 "Exclude files and folders:"
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                    {
                                                            Line 8 $item
                                                    }
     
                                                    Line 7 "Exclude processes:"
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                    {
                                                            Line 8 $item
                                                    }
                                                    
                                                    Line 7 "Exclude extensions:"
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                    {
                                                            Line 8 $item
                                                    }
                                            }
                                            
                                            Line 0 ""
                                    }
                                    
                                    Line 5 "Windows Components: " $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                    {
                                            Line 6 "Windows Components Optimizations"
                                            Line 7 "Disable (remove) components:"
                                            Line 0 ""
                                            Line 7 "Display name                                        Component                                         "
                                            Line 7 "======================================================================================================"
                                            #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890
                                            #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component
                                            <#
                                                              Type ComponentName                 DisplayName Aliases
                                                              ---- -------------                 ----------- -------
                                                    Predefined MSRDC-Infrastructure
                                                    Predefined MediaPlayback
                                                    Predefined WindowsMediaPlayer
                                                    Predefined Printing-XPSServices-Features
                                                    Predefined SMB1Protocol
                                                    Predefined SearchEngine-Client-Package
                                                    Predefined Xps-Foundation-Xps-Viewer                                    
                                            #>
                                            ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)
                                            {
                                                    Line 7 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)
                                            }
                                            Line 0 ""
                                    }
                                    
                                    Line 5 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                    {
                                            Line 6 "Windows Services Optimizations"
                                            Line 7 "Disable services:"
                                            Line 0 ""
                                            Line 7 "Display name                                        Service                         Aliases             "
                                            Line 7 "========================================================================================================"
                                            #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890
                                            #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth
                                            <#
                                                              Type ServiceName        DisplayName Aliases
                                                              ---- -----------        ----------- -------
                                                    Predefined AJRouter
                                                    Predefined ALG
                                                    Predefined BTAGService
                                                    Predefined BthAvctpSvc
                                                    Predefined CscService
                                                    Predefined DOT3SVC
                                                    Predefined DPS
                                                    Predefined DiagTrack
                                                    Predefined EFS
                                                    Predefined FDResPub
                                                    Predefined MapsBroker
                                                    Predefined SSDPSRV
                                                    Predefined SensrSvc
                                                    Predefined SharedAccess
                                                    Predefined ShellHWDetection
                                                    Predefined StorSvc
                                                    Predefined Sysmain
                                                    Predefined Superfetch
                                                    Predefined TabletInputService
                                                    Predefined TapiSrv
                                                    Predefined Themes
                                                    Predefined WMPNetworkSvc
                                                    Predefined WbioSrvc
                                                    Predefined WdiSystemHost
                                                    Predefined WerSvc
                                                    Predefined bthserv
                                                    Predefined fdPHost
                                                    Predefined lfsvc
                                                    Predefined upnphost
                                                    Predefined wbengine
                                                    Predefined wisvc
                                                    Predefined wlidsvc                                      
                                            #>
                                            ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)
                                            {
                                                    Line 7 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)
                                            }
                                            Line 0 ""
                                    }
                                    
                                    Line 5 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            Line 6 "Windows Scheduled Tasks Optimizations"
                                            Line 7 "Disable tasks:"
                                            Line 0 ""
                                            Line 7 "Task                                                Type    Location                                          "
                                            Line 7 "=============================================================================================================="
                                            #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890
                                            #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\
                                            <#
                                                    Task                Location                                        Type
                                                    ----                --------                                        ----
                                                    *                   \Microsoft\Windows\Application Experience     Folder
                                                    *                   \Microsoft\Windows\BitLocker                  Folder
                                                    CDSSync             \Microsoft\Windows\WlanSvc\                     Task
                                                    *                   \Microsoft\OneCore\DirectX                    Folder
                                                    GatherNetworkInfo   \Microsoft\Windows\NetTrace\                    Task
                                                    MNO Metadata Parser \Microsoft\Windows\Mobile Broadband Accounts\   Task
                                                    NotificationTask    \Microsoft\Windows\WwanSvc\                     Task
                                                    *                   \Microsoft\Office                             Folder
                                                    QueueReporting      \Microsoft\Windows\Windows Error Reporting\     Task
                                                    SR                  \Microsoft\Windows\SystemRestore\               Task
                                                    ScheduledDefrag     \Microsoft\Windows\Defrag\                      Task
                                                    Scheduled Start     \Microsoft\Windows\WindowsUpdate\               Task
                                                    *                   \Microsoft\Windows\Sysmain                    Folder
                                                    Tpm-HASCertRetr     \Microsoft\Windows\TPM\                         Task
                                                    Tpm-Maintenance     \Microsoft\Windows\TPM\                         Task
                                                    UninstallDeviceTask \Microsoft\Windows\Bluetooth\                   Task
                                                    UpdateLibrary       \Microsoft\Windows\Windows Media Sharing\       Task
                                                    *                   \Microsoft\Windows\Windows Defender           Folder
                                                    XblGameSaveTask     \Microsoft\XblGameSave\                         Task
                                                    sihpostreboot       \Microsoft\Windows\WindowsUpdate\               Task                                        
                                            #>
                                            ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                            {
                                                    Line 7 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)
                                            }
                                            Line 0 ""
                                    }
     
                                    Line 5 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            Line 6 "Windows Advanced Options"
                                            Line 0 ""
                                            Line 7 "Setting                                           Enabled  Value                                             "
                                            Line 7 "============================================================================================================="
                                            #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890
                                            #               Remove Common program groups from the start menu  False    SomeConfigFile.xml
                                            <#
                                                    PartialStartLayoutContent   : Configuration.xml
                                                    Hibernate                   : True
                                                    TeleCollection              : True
                                                    SystemRestore               : True
                                                    AdditionalErrorReport       : True
                                                    Tiles                       : True
                                                    Cortana                     : True
                                                    MicrosoftConsumerExperience : True
                                                    WindowsTips                 : True
                                                    CommonProgramGroups         : True
                                                    PartialStartMenu            : True
                                            #>
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Hibernate", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Telemetry collection", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable System Restore", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable error reporting to send additional data", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Tiles", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Cortana digital assistant", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Turn off Microsoft consumer experience", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Do not show Windows tips", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Remove Common program groups from the Start Menu", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Partial Start Menu layout", `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `
                                            $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)
                                            
                                            Line 0 ""
                                    }
     
                                    Line 5 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTNetworkPerformanceEnabled -eq "True")
                                    {
                                            Line 6 "Network Performance Optimizations"
                                            Line 0 ""
                                            Line 7 "Setting                      Enabled  Value"
                                            Line 7 "==========================================="
                                            #               123456789012345678901234567SS1234567SS12345
                                            #               FileNotFoundCacheEntriesMax  False    32768
                                            <#
                                                    DirCacheMax             : 4096
                                                    DormantFileLimit        : 256
                                                    FileNotFoundCache       : 32768
                                                    FileInfoCache           : 32768
                                                    FileInfoCacheEnable     : True
                                                    DirectoryCacheEnable    : True
                                                    FileNotFoundCacheEnable : True
                                                    DormantFileLimitEnable  : True
                                                    DisableTCP              : True
                                                    DisableIPv6CompEnable   : True
                                                    DisableIPv6ToIPv4       : True
                                                    DisableIsaTap           : True
                                            #>
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "FileInfoCacheEntriesMax", `
                                            $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `
                                            $RDSHost.Optimization.NetworkPerformance.FileInfoCache)
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "DirectoryCacheEntriesMax", `
                                            $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `
                                            $RDSHost.Optimization.NetworkPerformance.DirCacheMax)
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "FileNotFoundCacheEntriesMax", `
                                            $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `
                                            $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache)
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "DormantFileLimit", `
                                            $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `
                                            $RDSHost.Optimization.NetworkPerformance.DormantFileLimit)
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable TCP/IP Task Offload", `
                                            $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable IPv6 Components", `
                                            $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable IPv6 to IPv4", `
                                            $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `
                                            "")
                                            
                                            Line 7 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disables isatap for IPv6", `
                                            $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `
                                            "")
                                            
                                            Line 0 ""
                                    }
     
                                    Line 5 "Registry: " $OPTRegistryEnabled
                                    If($OPTRegistryEnabled -eq "True")
                                    {
                                            Line 6 "Registry Optimizations"
                                            Line 0 ""
                                            #               123456789012345678901234567SS1234567SS12345
                                            #               FileNotFoundCacheEntriesMax  False    32768
                                            <#
                                                    Id           : 1
                                                    Action       : Modify
                                                    RegistryName : ServicesPipeTimeout
                                                    DWORDValue   : 18000
                                                    DisplayName  : Increase service startup timeouts
                                                    HiveType     : HKEY_LOCAL_MACHINE
                                                    Path         : System\CurrentControlSet\Control
                                                    RegType      : REG_DWORD
     
                                                    Id           : 2
                                                    Action       : Modify
                                                    RegistryName : TimeOutValue
                                                    DWORDValue   : 200
                                                    DisplayName  : Increase Disk I/O Timeout
                                                    HiveType     : HKEY_LOCAL_MACHINE
                                                    Path         : System\CurrentControlSet\Services\Disk
                                                    RegType      : REG_DWORD
                                            #>
                                            Line 7 "Registry                                  Action  Value                 Type           Data                  Path                                                        "
                                            Line 7 "========================================================================================================================================================================="
                                            #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890
                                            #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk
                                            ForEach($item in $RDSHost.Optimization.Registry.RegistryList)
                                            {
                                                    Line 7 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `
                                                    $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType, $item.DWORDValue, "$($item.HiveType)\$($item.Path)")
                                            }
                                            Line 0 ""
                                    }
     
                                    Line 5 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                    {
                                            Line 6 "Visual Effects Optimizations"
                                            Line 0 ""
                                            
                                            Switch ($RDSHost.Optimization.VisualEffects.VisualEffectsTypes)
                                            {
                                                    "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}
                                                    "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs
                                                    "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}
                                                    "Custom"                                        {$VisualEffectsType = "Custom"; Break}
                                                    Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($RDSHost.Optimization.VisualEffects.VisualEffectsTypes)"; Break}
                                            }
                                            Line 7 $VisualEffectsType
                                            Line 0 ""
                                            Line 7 "Setting                                             Enabled"
                                            Line 7 "==========================================================="
                                            #               12345678901234567890123456789012345678901234567890SS1234567
                                            #               Use drop shadows for icon labels on the desktop     False  
                                            <#
                                                    VisualEffectsTypes                     : Custom
                                                    AnimateControlSelectElements           : False
                                                    AnimateWindowsWhenMinimizingMaximizing : False
                                                    AnimateTaskbar                         : False
                                                    EnablePeek                             : False
                                                    FadeSlideMenus                         : False
                                                    FadeSlideToolTips                      : False
                                                    FadeOutMenuItems                       : False
                                                    SaveTaskbarThumbnail                   : False
                                                    ShowShadowUnderMouse                   : False
                                                    ShadowUnderWindows                     : False
                                                    ThumbnailsInsteadOfIcons               : False
                                                    ShowTranslucentSelection               : False
                                                    ShowWindowsContentWhilstDragging       : False
                                                    SlideOpenComboBoxes                    : False
                                                    SmoothEdgesScreenFonts                 : True
                                                    SmoothScrollListBoxes                  : False
                                                    DropShadowsIcon                        : False
                                            #>
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Animate controls and elements inside windows", `
                                            $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Animate windows when minimizing and maximizing", `
                                            $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Animations in the taskbar", `
                                            $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Enable Peek", `
                                            $RDSHost.Optimization.VisualEffects.EnablePeek.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Fade or slide menus into view", `
                                            $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Fade or slide Tooltips into view", `
                                            $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Fade out menu items after clicking", `
                                            $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Save taskbar thumbnail previews", `
                                            $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show shadows under mouse pointer", `
                                            $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show shadows under windows", `
                                            $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show thumbnails instead of icons", `
                                            $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show translucent selection rectangle", `
                                            $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Show window contents while dragging", `
                                            $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Slide open combo boxes", `
                                            $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Smooth edges of screen fonts", `
                                            $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Smooth-scroll list boxes", `
                                            $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())
                                            
                                            Line 7 ( "{0,-50}  {1,-7}" -f `
                                            "Use drop shadows for icon labels on the desktop", `
                                            $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString())
                                            
                                            Line 0 ""
                                    }
     
                                    Line 5 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                    {
                                            Line 6 "Disk Cleanup Optimizations"
                                            Line 0 ""
                                            
                                            Line 7 "Setting                            Enabled"
                                            Line 7 "=========================================="
                                            #               123456789012345678901234567890123SS1234567
                                            #               Clean up temporary files and logs  False  
                                            <#
                                                    CleanupWinSxSFolder      : False
                                                    CleanupSystemFiles       : False
                                                    CleanupTemporaryFileLogs : True
                                                    RemoveOneDrive           : False
                                                    DeleteUserProfiles       : False
                                            #>
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up redundant system files", `
                                            $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString())
                                            
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up the WinSxS Folder", `
                                            $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())
                                            
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up temporary files and logs", `
                                            $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())
                                            
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Remove OneDrive", `
                                            $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString())
                                            
                                            Line 7 ( "{0,-33}  {1,-7}" -f `
                                            "Delete users' profiles", `
                                            $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString())
                                            
                                            Line 0 ""
                                    }
     
                                    Line 5 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled  -eq "True")
                                    {
                                            Line 6 "Custom Script"
                                            Line 0 ""
                                            
                                            <#
                                                    Arguments : CustomScriptArguments
                                                    Command   : CustomScriptCommand
                                                    InitDir   : CustomScriptInitialDirectory
                                                    User      : CustomScriptUsername
                                            #>
                                            Line 7 "Command`t`t : " $RDSHost.Optimization.CustomScript.Command
                                            Line 7 "Arguments`t : " $RDSHost.Optimization.CustomScript.Arguments
                                            Line 7 "Initial directory: " $RDSHost.Optimization.CustomScript.InitDir
                                            Line 7 "Username`t : " $RDSHost.Optimization.CustomScript.User
                                            Line 0 ""
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$RDSHost.InheritDefaultOptimizationSettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Enable optimization",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))
                                    $rowdata += @(,("Optimization type",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))
     
                                    $msg = "Optimization"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)
     
                                            If($RDSHost.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                            {
                                                    $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))
                                                    $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $RDSHost.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))
                                                    $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                    }
     
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                    }
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $RDSHost.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                    {
                                                            $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                            }
                                                    }
                                            }
     
     
                                            $msg = ""
                                            $columnWidths = @("300","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Components Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSHost.Optimization.WindowsComponents.WindowsComponentsList)
                                            {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.ComponentName,$htmlwhite)
                                                    )
                                            }
     
                                            $columnHeaders = @(
                                                    "Display Name",($Script:htmlsb),
                                                    "Component",($Script:htmlsb)
                                            )
     
                                            $msg = "Disable (remove) components:"
                                            $columnWidths = @("200","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Services Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSHost.Optimization.WindowsServices.WindowsServicesList)
                                            {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.ServiceName,$htmlwhite,
                                                            $item.Aliases,$htmlwhite)
                                                    )
                                            }
     
                                            $columnHeaders = @(
                                                    "Display Name",($Script:htmlsb),
                                                    "Service",($Script:htmlsb),
                                                    "Aliases",($Script:htmlsb)
                                            )
     
                                            $msg = "Disable services:"
                                            $columnWidths = @("200","100","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSHost.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                            {
                                                    $rowdata += @(,(
                                                            $item.Task,$htmlwhite,
                                                            $item.Type.Tostring(),$htmlwhite,
                                                            $item.Location,$htmlwhite)
                                                    )
                                            }
     
                                            $columnHeaders = @(
                                                    "Task",($Script:htmlsb),
                                                    "Type",($Script:htmlsb),
                                                    "Location",($Script:htmlsb)
                                            )
     
                                            $msg = "Disable tasks:"
                                            $columnWidths = @("200","50","250")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Advanced Options"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Disable Hibernate",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Telemetry collection",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable System Restore",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable error reporting to send additional data",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Tiles",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Cortana digital assistant",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Turn off Microsoft consumer experience",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Do not show Windows tips",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Remove Common program groups from the Start Menu",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Partial Start Menu layout",$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb),
                                                    "Value",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("300","50","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Network Performance Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "FileInfoCacheEntriesMax",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "DirectoryCacheEntriesMax",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "FileNotFoundCacheEntriesMax",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "DormantFileLimit",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable TCP/IP Task Offload",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable IPv6 Components",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable IPv6 to IPv4",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disables isatap for IPv6",$htmlwhite,
                                                    $RDSHost.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb),
                                                    "Value",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("170","50","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled       
                                    If($OPTRegistryEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Registry Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSHost.Optimization.Registry.RegistryList)
                                            {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.Action,$htmlwhite,
                                                            $item.RegistryName,$htmlwhite,
                                                            $item.RegType,$htmlwhite,
                                                            $item.DWORDValue,$htmlwhite,
                                                            "$($item.HiveType)\$($item.Path)",$htmlwhite)
                                                    )
                                            }
     
                                            $columnHeaders = @(
                                                    "Registry",($Script:htmlsb),
                                                    "Action",($Script:htmlsb),
                                                    "Value",($Script:htmlsb),
                                                    "Type",($Script:htmlsb),
                                                    "Data",($Script:htmlsb),
                                                    "Path",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("200","50","100","100","100","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Visual Effects Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Animate controls and elements inside windows",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Animate windows when minimizing and maximizing",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Animations in the taskbar",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Enable Peek",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade or slide menus into view",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade or slide Tooltips into view",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade out menu items after clicking",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Save taskbar thumbnail previews",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show shadows under mouse pointer",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show shadows under windows",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show thumbnails instead of icons",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show translucent selection rectangle",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show window contents while dragging",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Slide open combo boxes",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Smooth edges of screen fonts",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Smooth-scroll list boxes",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Use drop shadows for icon labels on the desktop",$htmlwhite,
                                                    $RDSHost.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("275","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Disk Cleanup Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Clean up redundant system files",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Clean up the WinSxS Folder",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Clean up temporary files and logs",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Remove OneDrive",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Delete users' profiles",$htmlwhite,
                                                    $RDSHost.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("200","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled -eq "True")
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)
                                            $rowdata += @(,("     Command",($Script:htmlsb), $RDSHost.Optimization.CustomScript.Command,$htmlwhite))
                                            $rowdata += @(,("     Arguments",($Script:htmlsb), $RDSHost.Optimization.CustomScript.Arguments,$htmlwhite))
                                            $rowdata += @(,("     Initial directory",($Script:htmlsb), $RDSHost.Optimization.CustomScript.InitDir,$htmlwhite))
                                            $rowdata += @(,("     Username",($Script:htmlsb), $RDSHost.Optimization.CustomScript.User,$htmlwhite))
     
                                            $msg = ""
                                            $columnWidths = @("125","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
     
                            #Desktop Access
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Desktop access"
                            }
                            If($Text)
                            {
                                    Line 3 "Desktop access"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($RDSHost.InheritDefaultDesktopAccessSettings)
                            {
                                    #do we inherit group or site defaults?
                                    #is this RDS host in a group?
                                    #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/
                                    #for translating the User SID to the AD user name
                                    $Results = Get-RASRDSGroup -SiteId $Site.Id -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $Results)
                                    {
                                            If($Results.RDSIds -Contains $RDSHost.Id )
                                            {
                                                    #does this group inherit default settings?
                                                    If($Results.InheritDefaultDesktopAccessSettings -eq $False)
                                                    {
                                                            #no we don't, so get the default settings for the group
                                                            $GroupDefaults = $Results.RDSDefSettings
     
                                                            $RDSRestrictDesktopAccess = $GroupDefaults.RestrictDesktopAccess.ToString()
                                                            $RDSRestrictedUsers       = @()
                                                            
                                                            ForEach($User in $GroupDefaults.RestrictedUsers)
                                                            {
                                                                    $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                                                    $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                                    
                                                                    $RDSRestrictedUsers += $objUser.Value
                                                            }
                                                    }
                                                    Else
                                                    {
                                                            #yes we do, get the default settings for the Site
                                                            #use the Site default settings
                                                            $RDSDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $RDSDefaults)
                                                            {
                                                                    $RDSRestrictDesktopAccess = $RDSDefaults.RestrictDesktopAccess.ToString()
                                                                    $RDSRestrictedUsers       = @()
                                                                    
                                                                    ForEach($User in $RDSDefaults.RestrictedUsers)
                                                                    {
                                                                            $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                                                            $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                                            
                                                                            $RDSRestrictedUsers += $objUser.Value
                                                                    }
                                                            }
                                                            Else
                                                            {
                                                                    #unable to retrieve default, use built-in default values
                                                                    $RDSRestrictDesktopAccess = "False"
                                                                    $RDSRestrictedUsers       = @()
                                                            }
                                                    }
                                            }
                                    }
                                    Else
                                    {
                                            #RDS Host is not in a group
                                            #get the settings for the host
                                            $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString()
                                            $RDSRestrictedUsers       = @()
                                            
                                            ForEach($User in $RDSHost.RestrictedUsers)
                                            {
                                                    $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                                    $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                                    
                                                    $RDSRestrictedUsers += $objUser.Value
                                            }
                                    }
                            }
                            Else
                            {
                                    #we don't inherit
                                    #get the settings for the host
                                    $RDSRestrictDesktopAccess = $RDSHost.RestrictDesktopAccess.ToString()
                                    $RDSRestrictedUsers       = @()
                                    
                                    ForEach($User in $RDSHost.RestrictedUsers)
                                    {
                                            $objSID  = New-Object System.Security.Principal.SecurityIdentifier ($User)
                                            $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
                                            
                                            $RDSRestrictedUsers += $objUser.Value
                                    }
                            }
                                    
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSHost.InheritDefaultDesktopAccessSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Restrict direct desktop access to the following users"; Value = $RDSRestrictDesktopAccess; }) > $Null
                                    
                                    $cnt = -1
                                    ForEach($Item in $RDSRestrictedUsers)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Users"; Value = $Item; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 250;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
 
  -+                                                         $RDSRemoveClientNameFromPrinter          = $GroupDefaults.RemoveClientNameFromPrinterName.ToString()
 
  -+                                                                 $RDSRemoveClientNameFromPrinter          = $RDSDefaults.RemoveClientNameFromPrinterName.ToString()
 
  -+                                                                 $RDSRemoveClientNameFromPrinter          = "False"
 
  -+                                         $RDSRemoveClientNameFromPrinter          = $RDSHost.RemoveClientNameFromPrinterName.ToString()
 
  -+                                 $RDSRemoveClientNameFromPrinter    = $RDSHost.RemoveClientNameFromPrinterName.ToString()
 
  -+                                 If($RDSHost.RemoveSessionNumberFromPrinterName)
                                    {
                                            $ScriptInformation.Add(@{Data = "Remove client name from printer name"; Value = $RDSRemoveClientNameFromPrinter; }) > $Null
                                    }
 
  -+                                 If($RDSHost.RemoveSessionNumberFromPrinterName)
                                    {
                                            Line 4 "Remove client name from printer name`t`t`t: " $RDSRemoveClientNameFromPrinter
                                    }
 
  -+                                 If($RDSHost.RemoveSessionNumberFromPrinterName)
                                    {
                                            $rowdata += @(,("Remove client name from printer name",($Script:htmlsb),$RDSRemoveClientNameFromPrinter,$htmlwhite))
                                    }
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host Groups" <>         Write-Verbose "$(Get-Date -Format G): `tOutput RD Session Host Groups"
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Groups"
            }
            If($Text)
            {
                    Line 1 "Groups"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Groups"
            }
     
 
                If($MSWord -or $PDF) <>                 ForEach($RDSGroup in $RDSGroups)
 
                        WriteWordLine 2 0 "Groups" <>                         Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host Group $($RDSGroup.Name)"
                }                           
                If($Text)                           #Get the agent state for the group
                            $RDSGroupStatus = Get-RASRDSGroupStatus -Name $RDSGroup.Name -EA 0 4>$Null
                            
                            If(!$? -or $Null -eq $RDSGroupStatus)
                {                           {
                        Line 1 "Groups"                                   $RDSGroupAgentState = "Unknown"
                }                           }
                If($HTML)                           Else
                {                           {
                        WriteHTMLLine 2 0 "Groups"                                   $RDSGroupAgentState = GetRASStatus $RDSGroupStatus.AgentState
                }                           }
                            
                ForEach($RDSGroup in $RDSGroups)    
                {    
                        Write-Verbose "$(Get-Date -Format G): `t`t`tOutput RD Session Host Group $($RDSGroup.Name)"    
 
  -+                                 $ScriptInformation.Add(@{Data = "Status"; Value = $RDSGroupAgentState; }) > $Null
 
  -+                                 Line 2 "Status`t`t`t: " $RDSGroupAgentState
 
  -+                                 $rowdata += @(,("Status",($Script:htmlsb),$RDSGroupAgentState,$htmlwhite))
 
  <>  
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 250;
                                    $Table.Columns.Item(2).Width = 250;
     
                                $ScriptInformation.Add(@{Data = "RD session hosts based on a template"; Value = $RDSGroup.UseRASTemplate; }) > $Null                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Enable Group in site`t: " $RDSGroup.Enabled.ToString()
                                    Line 3 "Name`t`t`t: " $RDSGroup.Name
                                    Line 3 "Description`t`t: " $RDSGroup.Description
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                $ScriptInformation.Add(@{Data = "RAS template"; Value = $RDSGroup.RASTemplateId; }) > $Null                                   $columnHeaders = @("Enable Group in site",($Script:htmlsb),$RDSGroup.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Name",($Script:htmlsb),$RDSGroup.Name,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$RDSGroup.Description,$htmlwhite))
     
                                    $msg = "General"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #Servers
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Servers"
                            }
                            If($Text)
                            {
                                    Line 2 "Servers"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
 
                                        $ScriptInformation.Add(@{Data = "Group Members"; Value = ""; }) > $Null +-  
 
  <>                                                 If($RDSGroupMember.Enabled)
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Enabled"
                                                    }
                                                    Else
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Disabled"
                                                    }
                                                    
                                                    $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null
                                                    
                                                    If($? -and $Null -ne $Status)
                                                    {
                                                            $AgentStatus = GetRASStatus $Status.AgentState
                                                $cnt++                                                           $cnt++
                                                $ScriptInformation.Add(@{Data = "     Member"; Value = $RDSGroupMember.Server; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Server"; Value = $RDSGroupMember.Server; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Logon status"; Value = $RDSGroupMember.Enabled.ToString(); }) > $Null                                                           $ScriptInformation.Add(@{Data = "Status"; Value = $AgentStatus; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Type"; Value = "Server"; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Logon status"; Value = $RDSGroupMemberLogonStatus; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Description"; Value = $RDSGroupMember.Description; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Description"; Value = $RDSGroupMember.Description; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Sessions"; Value = $Status.ActiveSessions.ToString(); }) > $Null
                                                If($RDSGroupMembers.Count -gt 1)                                                           If($RDSGroupMembers.Count -gt 1)
                                                {                                                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                            }
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Server"; Value = "Error retrieving server $($RDSGroupMember.Server) status"; }) > $Null
 
                                Line 3 "Enable Group in site`t`t`t: " $RDSGroup.Enabled.ToString() +-  
                                Line 3 "Name`t`t`t`t`t: " $RDSGroup.Name    
                                Line 3 "Description`t`t`t`t: " $RDSGroup.Description    
                                Line 3 "RD session hosts based on a template`t: " $RDSGroup.UseRASTemplate    
                                Line 3 "RAS template`t`t`t`t: " $RDSGroup.RASTemplateId    
 
                                        Line 3 "Group Members" "" +-  
 
  <>                                                 If($RDSGroupMember.Enabled)
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Enabled"
                                                    }
                                                    Else
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Disabled"
                                                    }
                                                            
                                                    $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null
                                                            
                                                    If($? -and $Null -ne $Status)
                                                    {
                                                            $AgentStatus = GetRASStatus $Status.AgentState
                                                $cnt++                                                           $cnt++
                                                Line 4 "Member`t`t: " $RDSGroupMember.Server                                                           Line 3 "Server`t`t: " $RDSGroupMember.Server
                                                            Line 3 "Status`t`t: " $AgentStatus
                                                Line 4 "Logon status`t: " $RDSGroupMember.Enabled.ToString()                                                           Line 3 "Logon status`t: " $RDSGroupMemberLogonStatus
                                                Line 4 "Type`t`t: " "Server"    
                                                Line 4 "Description`t: " $RDSGroupMember.Description                                                           Line 3 "Description`t: " $RDSGroupMember.Description
                                                            Line 3 "Sessions`t: " $Status.ActiveSessions.ToString()
                                                If($RDSGroupMembers.Count -gt 1)                                                           If($RDSGroupMembers.Count -gt 1)
                                                {                                                           {
                                                        Line 4 ""                                                                   Line 3 ""
                                                            }
                                                    }
                                                    Else
                                                    {
                                                            Line 3 "Server`t`t: " "Error retrieving server $($RDSGroupMember.Server) status"
 
                                $columnHeaders = @("Enable Group in site",($Script:htmlsb),$RDSGroup.Enabled.ToString(),$htmlwhite) +-  
                                $rowdata += @(,("Name",($Script:htmlsb),$RDSGroup.Name,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSGroup.Description,$htmlwhite))    
                                $rowdata += @(,("RD session hosts based on a template",($Script:htmlsb),$RDSGroup.UseRASTemplate.ToString(),$htmlwhite))    
                                $rowdata += @(,("RAS template",($Script:htmlsb),$RDSGroup.RASTemplateId.ToString(),$htmlwhite))    
 
                                        $rowdata += @(,("Group Members",($Script:htmlsb),"",$htmlwhite)) +-  
 
  <>                                                 If($RDSGroupMember.Enabled)
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Enabled"
                                                    }
                                                    Else
                                                    {
                                                            $RDSGroupMemberLogonStatus = "Disabled"
                                                    }
                                                            
                                                    $Status = Get-RASRDSStatus -Server $RDSGroupMember.Server  -EA 0 4>$Null
                                                    
                                                    If($? -and $Null -ne $Status)
                                                    {
                                                            $AgentStatus = GetRASStatus $Status.AgentState
                                                $cnt++                                                           $cnt++
                                                            If($cnt -eq 0)
                                                            {
                                                                    $columnHeaders = @("Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite)
                                                            }
                                                            Else
                                                            {
                                                $rowdata += @(,("     Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite))                                                                   $rowdata += @(,("Member",($Script:htmlsb),$RDSGroupMember.Server,$htmlwhite))
                                                            }
                                                $rowdata += @(,("     Logon status",($Script:htmlsb),$RDSGroupMember.Enabled.ToString(),$htmlwhite))                                                           $rowdata += @(,("Status",($Script:htmlsb),$AgentStatus,$htmlwhite))
                                                $rowdata += @(,("     Type",($Script:htmlsb),"Server",$htmlwhite))                                                           $rowdata += @(,("Logon status",($Script:htmlsb),$RDSGroupMemberLogonStatus,$htmlwhite))
                                                $rowdata += @(,("     Description",($Script:htmlsb),$RDSGroupMember.Description,$htmlwhite))                                                           $rowdata += @(,("Description",($Script:htmlsb),$RDSGroupMember.Description,$htmlwhite))
                                                            $rowdata += @(,("Sessions",($Script:htmlsb),$Status.ActiveSessions.ToString(),$htmlwhite))
                                                If($RDSGroupMembers.Count -gt 1)                                                           If($RDSGroupMembers.Count -gt 1)
                                                {                                                           {
                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                            }
 
  -+                                                 Else
                                                    {
                                                            $rowdata += @(,("Server",($Script:htmlsb),"Error retrieving server $($RDSGroupMember.Server) status",$htmlwhite))
                                                    }
 
                                $msg = "General" <>                                 $msg = "Servers"
 
                                                "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                                 "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
                                                "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                                   "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
                                                "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                                   "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                                     $ReplaceRegisteredApplication = "True";
                                                                                                                     Break}
                                                Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)"; Break}                                                   Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSDefaults.AllowURLAndMailRedirection)";
                                                                                                                     $ReplaceRegisteredApplication = "False";
                                                                                                                     Break}
 
                                                "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                                 "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                                   "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                                    $RDSAllowDragAndDrop = "False";
                                                    Break}
                                                "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                                   "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                                   "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                                    $RDSAllowDragAndDrop = "True";
                                                    Break}
                                                Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)"; Break}                                                   Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSDefaults.DragAndDropMode)";
                                                    $RDSAllowDragAndDrop = "False";
                                                    Break}
 
                                        If($RDSDefaults.PreferredPAId -eq 0) <>                                         If($RDSDefaults.PreferredBrokerId -eq 0)
 
                                                $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSDefaults.PreferredPAId -EA 0 4>$Null).Server <>                                                 $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSDefaults.PreferredBrokerId -EA 0 4>$Null).Server
 
  -+                                         $ReplaceRegisteredApplication          = "False"
 
  -+                                         $RDSAllowDragAndDrop                   = "True"
 
                                        "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled"; Break} <>                                         "Enabled"                                               {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                        "Disbaled"                                              {$RDSAllowClientURLMailRedirection = "Disabled"; Break}                                           "Disabled"                                              {$RDSAllowClientURLMailRedirection = "Disabled";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                        "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled (Replace Registered Application)"; Break}                                           "EnabledWithAppRegistration"    {$RDSAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "True";
                                                                                                             Break}
                                        Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSGroup.AllowURLAndMailRedirection)"; Break}                                           Default                                                 {$RDSAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($RDSGroupDefaults.AllowURLAndMailRedirection)";
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
 
                                        "Bidirectional"         {$RDSDragAndDrop = "Bidirectional"; Break} <>                                         "Bidirectional"         {$RDSDragAndDrop = "Bidirectional";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        "Disabled"                      {$RDSDragAndDrop = "Disabled"; Break}                                           "Disabled"                      {$RDSDragAndDrop = "Disabled";
                                            $RDSAllowDragAndDrop = "False";
                                            Break}
                                        "ClientToServer"        {$RDSDragAndDrop = "Client to server only"; Break}                                           "ClientToServer"        {$RDSDragAndDrop = "Client to server only";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        "ServerToClient"        {$RDSDragAndDrop = "Server to client only"; Break}                                           "ServerToClient"        {$RDSDragAndDrop = "Server to client only";
                                            $RDSAllowDragAndDrop = "True";
                                            Break}
                                        Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSGroup.DragAndDropMode)"; Break}                                           Default                         {$RDSDragAndDrop = "Unable to determine Drag and drop: $($RDSGroupDefaults.DragAndDropMode)";
                                            $RDSAllowDragAndDrop = "False";
                                            Break}
 
                                If($RDSGroupDefaults.PreferredPAId -eq 0) <>                                 If($RDSGroupDefaults.PreferredBrokerId -eq 0)
 
                                        $RDSPreferredPublishingAgent = (Get-RASPA -Id $RDSGroupDefaults.PreferredPAId -EA 0 4>$Null).Server <>                                         $RDSPreferredPublishingAgent = (Get-RASBroker -Id $RDSGroupDefaults.PreferredBrokerId -EA 0 4>$Null).Server
 
  <>                                 $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Disconnect active session after"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Logoff disconnected session after"; Value = $RDSPublishingSessionResetTime; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Other settings"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "Port"; Value = $RDSPort; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Port"; Value = $RDSPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "Max Sessions"; Value = $RDSMaxSessions; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Max Sessions"; Value = $RDSMaxSessions; }) > $Null
                                $ScriptInformation.Add(@{Data = "Publishing Session Disconnect Timeout"; Value = $RDSPublishingSessionDisconnectTimeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Publishing Session Reset Timeout"; Value = $RDSPublishingSessionResetTime; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Preferred Connection Broker"; Value = $RDSPreferredPublishingAgent; }) > $Null
 
  <>                                 $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null
                                $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $RDSSupportShellURLNamespaceObject; }) > $Null
                                $ScriptInformation.Add(@{Data = "Drag and drop"; Value = $RDSDragAndDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $RDSAllowDragandDrop; }) > $Null
                                $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $RDSPreferredPublishingAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSDragAndDrop; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $RDSAllowFileTransfer; }) > $Null
                                $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $RDSFileTransferMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Direction"; Value = $RDSFileTransferMode; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Location"; Value = $RDSFileTransferLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Location"; Value = $RDSFileTransferLocation; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $RDSFileTransferChangeLocation; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $RDSEnableDriveRedirectionCache; }) > $Null
 
                                Line 3 "Inherit default settings`t`t`t`t: " $RDSGroup.InheritDefaultAgentSettings.ToString() <>                                 Line 3 "Inherit default settings`t`t`t`t`t: " $RDSGroup.InheritDefaultAgentSettings.ToString()
                                    Line 3 "Application session lingering"
                                    Line 4 "Disconnect active session after`t`t`t`t: " $RDSPublishingSessionDisconnectTimeout
                                    Line 4 "Logoff disconnected session after`t`t`t: " $RDSPublishingSessionResetTime
                                    Line 3 "Other settings"
                                Line 3 "Port`t`t`t`t`t`t`t: " $RDSPort                                   Line 4 "Port`t`t`t`t`t`t`t: " $RDSPort
                                Line 3 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions                                   Line 4 "Max Sessions`t`t`t`t`t`t: " $RDSMaxSessions
                                Line 3 "Publishing Session Disconnect Timeout`t`t`t: " $RDSPublishingSessionDisconnectTimeout    
                                Line 3 "Publishing Session Reset Timeout`t`t`t: " $RDSPublishingSessionResetTime                                   Line 4 "Preferred Connection Broker`t`t`t`t: " $RDSPreferredPublishingAgent
                                Line 3 "Allow Client URL/Mail Redirection`t`t`t: " $RDSAllowClientURLMailRedirection                                   Line 3 "Allow Client URL/Mail Redirection`t`t`t`t: " $RDSAllowClientURLMailRedirection
                                    Line 4 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication
                                Line 3 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject                                   Line 4 "Support Windows Shell URL namespace objects`t`t: " $RDSSupportShellURLNamespaceObject
                                Line 3 "Drag and drop`t`t`t`t`t`t: " $RDSDragAndDrop                                   Line 3 "Enable Drag and drop`t`t`t`t`t`t: " $RDSAllowDragandDrop
                                Line 3 "Preferred Publishing Agent`t`t`t`t: " $RDSPreferredPublishingAgent                                   Line 4 "Direction`t`t`t`t`t`t: " $RDSDragAndDrop
                                Line 3 "Allow 2xRemoteExec to send command to the client`t: " $RDSAllowRemoteExec                                   Line 3 "Allow 2xRemoteExec to send command to the client`t`t: " $RDSAllowRemoteExec
                                Line 3 "Use RemoteApp if available`t`t`t`t: " $RDSUseRemoteApps                                   Line 3 "Use RemoteApp if available`t`t`t`t`t: " $RDSUseRemoteApps
                                Line 3 "Enable applications monitoring`t`t`t`t: " $RDSEnableAppMonitoring                                   Line 3 "Enable applications monitoring`t`t`t`t`t: " $RDSEnableAppMonitoring
                                Line 3 "Allow file transfer command (HTML5 and Chrome clients)`t: " $RDSAllowFileTransfer                                   Line 3 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $RDSAllowFileTransfer
                                Line 3 "Configure File Transfer"                                   Line 4 "Configure File Transfer"
                                Line 4 "Direction`t`t`t: " $RDSFileTransferMode                                   Line 5 "Direction`t`t`t: " $RDSFileTransferMode
                                Line 4 "Location`t`t`t: " $RDSFileTransferLocation                                   Line 5 "Location`t`t`t: " $RDSFileTransferLocation
                                Line 4 "Do not allow to change location`t: " $RDSFileTransferChangeLocation                                   Line 5 "Do not allow to change location : " $RDSFileTransferChangeLocation
                                    Line 3 "Enable drive redirection cache`t`t`t`t`t: " $RDSEnableDriveRedirectionCache
 
  <>                                 $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Disconnect active session after",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))
                                    $rowdata += @(,("     Logoff disconnected session after",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))
                                    $rowdata += @(,("Other settings",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("Port",($Script:htmlsb),$RDSPort,$htmlwhite))                                   $rowdata += @(,("     Port",($Script:htmlsb),$RDSPort,$htmlwhite))
                                $rowdata += @(,("Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))                                   $rowdata += @(,("     Max Sessions",($Script:htmlsb),$RDSMaxSessions,$htmlwhite))
                                $rowdata += @(,("Publishing Session Disconnect Timeout",($Script:htmlsb),$RDSPublishingSessionDisconnectTimeout,$htmlwhite))    
                                $rowdata += @(,("Publishing Session Reset Timeout",($Script:htmlsb),$RDSPublishingSessionResetTime,$htmlwhite))                                   $rowdata += @(,("     Preferred Connection Broker",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))
 
  <>                                 $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite))
                                $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))                                   $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$RDSSupportShellURLNamespaceObject,$htmlwhite))
                                $rowdata += @(,("Drag and drop",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))                                   $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$RDSAllowDragandDrop,$htmlwhite))
                                $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$RDSPreferredPublishingAgent,$htmlwhite))                                   $rowdata += @(,("     Direction",($Script:htmlsb),$RDSDragAndDrop,$htmlwhite))
 
                                $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite)) <>                                 $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$RDSAllowFileTransfer,$htmlwhite))
                                $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("     Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))                                   $rowdata += @(,("          Direction",($Script:htmlsb),$RDSFileTransferMode,$htmlwhite))
                                $rowdata += @(,("     Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))                                   $rowdata += @(,("          Location",($Script:htmlsb),$RDSFileTransferLocation,$htmlwhite))
                                $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))                                   $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$RDSFileTransferChangeLocation,$htmlwhite))
                                    $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$RDSEnableDriveRedirectionCache,$htmlwhite))
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host Scheduler" <>         Write-Verbose "$(Get-Date -Format G): `tOutput RD Session Hosts Templates"
        $RDSSchedules = Get-RASRDSSchedule -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)           If($MSWord -or $PDF)
                {           {
                        WriteWordLine 0 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"                   WriteWordLine 2 0 "Templates"
                }           }
                If($Text)           If($Text)
                {           {
                        Line 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"                   Line 1 "Templates"
                }           }
                If($HTML)           If($HTML)
                {           {
                        WriteHTMLLine 0 0 "Unable to retrieve RD Session Host Scheduler for Site $($Site.Name)"                   WriteHTMLLine 2 0 "Templates"
                }           }
                    
            $RDSTemplates = Get-RASVDITemplate -Siteid $Site.Id -EA 0 4>$Null | Where-Object {$_.TemplateType -eq "RDSH"}
        }    
        ElseIf($? -and $Null -eq $RDSSchedules)           If(!$?)
 
                Write-Host " <>                 Write-Warning "
                    `n
                No RD Session Host Scheduler retrieved for Site $($Site.Name).`                   Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)`
                " -ForegroundColor White                   "
 
                        WriteWordLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)"
 
                        Line 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve RD Session Hosts Templates for Site $($Site.Name)"
 
        Else <>         ElseIf($? -and $Null -eq $RDSTemplates)
 
  -+                 Write-Host "
                    No RD Session Hosts Templates retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
 
                        WriteWordLine 2 0 "Scheduler" <>                         WriteWordLine 0 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)"
 
                        Line 1 "Scheduler" <>                         Line 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 2 0 "Scheduler" <>                         WriteHTMLLine 0 0 "No RD Session Hosts Templates retrieved for Site $($Site.Name)"
 
  <>  
                ForEach($RDSSchedule in $RDSSchedules)    
                {    
                        Write-Verbose "$(Get-Date -Format G): `t`t`tOutput RD Session Host Scheduler $($RDSSchedule.Name)"    
                        $Action = $RDSSchedule.Action    
                        If($RDSSChedule.Action -eq "Reboot")    
                        {    
                                If($RDSSchedule.DrainMode)    
                                {    
                                        $Action = "Reboot - Drain Mode"    
                                }           }
                                Else           Else
                                {           {
                                        $Action = "Reboot"    
                                }    
                        }    
     
                        If($Action -eq "Reboot - Drain Mode")    
                        {    
                                Switch ($RDSSchedule.CompleteRebootInSecs)                   ForEach($RDSTemplate in $RDSTemplates)
                                {                   {
                                        600             {$TimeDuration = "10 minutes"; Break}    
                                        900             {$TimeDuration = "15 minutes"; Break}    
                                        1800    {$TimeDuration = "30 minutes"; Break}    
                                        2700    {$TimeDuration = "45 minutes"; Break}    
                                        3600    {$TimeDuration = "1 hour"; Break}    
                                        7200    {$TimeDuration = "2 hours"; Break}    
                                        10800   {$TimeDuration = "3 hours"; Break}    
                                        Default {$TimeDuration = "Unable to determine Complete in seconds: $($RDSSchedule.CompleteRebootInSecs)"; Break}                           Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host Template $($RDSTemplate.Name)"
                                }                           $TemplateProvider = Get-RASProvider -Id $RDSTemplate.ProviderId -EA 0 4>$Null
                                    
                                Switch ($RDSSchedule.ForceRebootAfterSecs)    
                                {    
                                        900             {$ForceRebootTime = "15 minutes"; Break}    
                                        1800    {$ForceRebootTime = "30 minutes"; Break}    
                                        2700    {$ForceRebootTime = "45 minutes"; Break}    
                                        3600    {$ForceRebootTime = "1 hour"; Break}    
                                        7200    {$ForceRebootTime = "2 hours"; Break}    
                                        10800   {$ForceRebootTime = "3 hours"; Break}    
                                        21600   {$ForceRebootTime = "6 hours"; Break}    
                                        43200   {$ForceRebootTime = "12 hours"; Break}    
                                        86400   {$ForceRebootTime = "1 day"; Break}    
                                        Default {$ForceRebootTime = "Unable to determine Force reboot after seconds: $($RDSSchedule.ForceRebootAfterSecs)"; Break}    
                                }    
                        }    
                        ElseIf($Action -eq "Disable")    
                        {    
                                Switch ($RDSSchedule.DurationInSecs)    
                                {    
                                        600             {$TimeDuration = "10 minutes"; Break}    
                                        900             {$TimeDuration = "15 minutes"; Break}    
                                        1800    {$TimeDuration = "30 minutes"; Break}    
                                        2700    {$TimeDuration = "45 minutes"; Break}    
                                        3600    {$TimeDuration = "1 hour"; Break}    
                                        7200    {$TimeDuration = "2 hours"; Break}    
                                        10800   {$TimeDuration = "3 hours"; Break}    
                                        21600   {$TimeDuration = "6 hours"; Break}    
                                        43200   {$TimeDuration = "12 hours"; Break}    
                                        86400   {$TimeDuration = "1 day"; Break}    
                                        Default {$TimeDuration = "Unable to determine Duration in seconds: $($RDSSchedule.DurationInSecs)"; Break}    
                                }    
                                    
                                Switch ($RDSSchedule.DisableAction)    
                                {    
                                        "KeepSessionState"                      {$OnDisable = "Keep current sessions state"; Break}    
                                        "DisconnectActiveSessions"      {$OnDisable = "Disconnect any active session"; Break}    
                                        "ResetAllSessions"                      {$OnDisable = "Reset all sessions"; Break}    
                                        Default                                         {$OnDisable = "Unable to determine On disable: $($RDSSchedule.DisableAction)"; Break}    
                                }    
                        }    
 
                        Switch ($RDSSchedule.Repeat) <>  
                        {    
                                Never                   {$Repeat = "Never "; Break}    
                                EveryDay                {$Repeat = "Every day"; Break}    
                                EveryWeek               {$Repeat = "Every week"; Break}    
                                Every2Weeks             {$Repeat = "Every 2 weeks"; Break}    
                                EveryMonth              {$Repeat = "Every month"; Break}    
                                EveryYear               {$Repeat = "Every year"; Break}    
                                SpecificDays    {$Repeat = "Every $($RDSSchedule.SpecificDays)"; Break}    
                                Default                 {$Repeat = "Unable to determine the Repeat: $($RDSSchedule.Repeat)"; Break}    
                        }    
                            
                        $Target = @()    
                        If($RDSSchedule.TargetType -eq "Server")    
                        {    
                                ForEach($Item in $RDSSchedule.TargetIds)    
                                {    
                                        $Result = Get-RASRDS -Id $Item -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $Result)                           If($? -and $Null -ne $TemplateProvider)
                                        {                           {
                                                $Target += $Result.Server                                   $TemplateProviderName = $TemplateProvider.Server
                                    $TemplateProviderType = GetVDIType $TemplateProvider.Type
                                        }                           }
                                        Else                           Else
                                        {                           {
                                                Target += "Unable to find RDS Server for ID $($Item)"                                   $TemplateProviderName = ""
                                        }                                   $TemplateProviderType = ""
                                }    
 
                        ElseIf($RDSSchedule.TargetType -eq "ServerGroup") <>  
                        {    
                                ForEach($Item in $RDSSchedule.TargetIds)                           $TemplateVM = Get-RASVM -Id $RDSTemplate.VMId -ProviderId $RDSTemplate.ProviderId -EA 0 4>$Null
                                {    
                                        $Result = Get-RASRDSGroup -Id $Item -EA 0 4>$Null    
                                                                  
                                        If($? -and $Null -ne $Result)                           If($? -and $Null -ne $TemplateVM)
                                        {                           {
                                                $Target += $Result.Name    
                                        }                                   <#
                                            Values          Description
                                            Unknown         The VM is in the 'Unknown' state
                                            On                  The VM is powered on.
                                            Off                 The VM is powered off
                                            Paused          The VM is already, or in the process of being, suspended
                                            CloningFailed   Failed to clone the VM.
                                            CloningCanceled VM cloning was cancelled
                                        Else                                   #>
                                    Switch($TemplateVM.State)
                                        {                                   {
                                            "Unknown"                       {$TemplatePowerState = "Unknown"; Break}
                                                Target += "Unable to find RDS Server Group for ID $($Item)"                                           "On"                            {$TemplatePowerState = "Powered on"; Break}
                                        }                                           "Off"                           {$TemplatePowerState = "Powered off"; Break}
                                            "Paused"                        {$TemplatePowerState = "Paused"; Break}
                                            "CloningFailed"         {$TemplatePowerState = "Cloning failed"; Break}
                                            "CloningCanceled"       {$TemplatePowerState = "Cloning canceled"; Break}
                                            Default                         {$TemplatePowerState = "Unable to determine template VM power state: $($TemplateVM.State)"; Break}
 
                                Target += "Unable to determine Target for TargetType: $($RDSSchedule.TargetType)" <>                                 $TemplatePowerState = "Unknown"
 
                                WriteWordLine 3 0 "Schedule Name $($RDSSchedule.Name)" <>                                 WriteWordLine 3 0 "Template Name $($RDSTemplate.Name)"
 
                                $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Name"; Value = $RDSTemplate.Name; }) > $Null
                                $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null                                   #$ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null                                   $ScriptInformation.Add(@{Data = "Power state"; Value = $TemplatePowerState; }) > $Null
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   #$ScriptInformation.Add(@{Data = "Agent status"; Value = "Can't find"; }) > $Null
                                        }    
                                }    
                                    
                                $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime; }) > $Null                                   #$ScriptInformation.Add(@{Data = "Distribution"; Value = "Can't find"; }) > $Null
                                $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null                                   $ScriptInformation.Add(@{Data = "Provider"; Value = $TemplateProviderName; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Provider type"; Value = $TemplateProviderType; }) > $Null
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSSchedule.AdminLastMod; }) > $Null                                   $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSTemplate.AdminLastMod; }) > $Null
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSSchedule.TimeLastMod.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSTemplate.TimeLastMod.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSSchedule.AdminCreate; }) > $Null                                   $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSTemplate.AdminCreate; }) > $Null
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSSchedule.TimeCreate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSTemplate.TimeCreate.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "ID"; Value = $RDSSchedule.Id.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "ID"; Value = $RDSTemplate.Id.ToString(); }) > $Null
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 250;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Name`t`t`t: " $RDSSchedule.Name    
                                Line 2 "Action`t`t`t: " $Action    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                Line 2 "Target`t`t`t: " $Item    
                                        }    
                                        Else    
                                        {    
                                                Line 6 "  " $Item    
                                        }    
                                }    
                                    
                                Line 2 "Start`t`t`t: " $RDSSchedule.StartDateTime    
                                Line 2 "Repeat`t`t`t: " $Repeat    
                                Line 2 "Description`t`t: " $RDSSchedule.Description    
                                Line 2 "Last modification by`t: " $RDSSchedule.AdminLastMod    
                                Line 2 "Modified on`t`t: " $RDSSchedule.TimeLastMod.ToString()    
                                Line 2 "Created by`t`t: " $RDSSchedule.AdminCreate    
                                Line 2 "Created on`t`t: " $RDSSchedule.TimeCreate.ToString()    
                                Line 2 "ID`t`t`t: " $RDSSchedule.Id.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 3 0 "Schedule Name $($RDSSchedule.Name)"    
                                $rowdata = @()    
                                $columnHeaders = @("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite)    
                                $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime,$htmlwhite))    
                                $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb),$RDSSchedule.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb),$RDSSchedule.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb),$RDSSchedule.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb),$RDSSchedule.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("ID",($Script:htmlsb),$RDSSchedule.Id.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        #Properties    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "General"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "General"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Enable Schedule"; Value = $RDSSchedule.Enabled.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
 
                                Line 3 "Enable Schedule`t`t`t: " $RDSSchedule.Enabled.ToString() <>  
                                Line 3 "Name`t`t`t`t: " $RDSSchedule.Name                                   Line 2 "Name: " $RDSTemplate.Name
                                Line 3 "Action`t`t`t`t: " $Action                                   #Line 2 "Status`t`t`t: " "Can't find"
                                Line 3 "Description`t`t`t: " $RDSSchedule.Description    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Target`t`t`t`t: " $Item    
                                        }    
                                        Else    
                                        {    
                                                Line 7 "  " $Item    
                                        }    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Enable schedule",($Script:htmlsb),$RDSSchedule.Enabled.ToString(),$htmlwhite)    
                                $rowdata += @(,("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite))    
                                $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))    
                                    
                                $cnt=-1    
                                ForEach($Item in $Target)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                $msg = "General"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Trigger    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Trigger"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Trigger"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Date"; Value = $RDSSchedule.StartDateTime.ToShortDateString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime.ToShortTimeString(); }) > $Null    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Complete in"; Value = $TimeDuration  ; }) > $Null    
                                }    
                                ElseIf($Action -eq "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Duration"; Value = $TimeDuration; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Date`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortDateString()    
                                Line 3 "Start`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortTimeString()    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        Line 3 "Complete in`t`t`t: " $TimeDuration                                   Line 2 "Power state`t`t: " $TemplatePowerState
                                }                                   #Line 2 "Agent status`t`t: " "Can't find"
                                ElseIf($Action -eq "Disable")    
                                {    
                                        Line 3 "Duration`t`t`t: " $TimeDuration                                   #Line 2 "Distribution`t`t: " "Can't find"
                                }    
                                Line 3 "Repeat`t`t`t`t: " $Repeat    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Date",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortDateString(),$htmlwhite)    
                                $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortTimeString(),$htmlwhite))    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $rowdata += @(,("Complete in",($Script:htmlsb),$TimeDuration,$htmlwhite))    
                                }    
                                ElseIf($Action -eq "Disable")    
                                {    
                                        $rowdata += @(,("Duration",($Script:htmlsb),$TimeDuration,$htmlwhite))    
                                }    
                                $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))    
     
                                $msg = "Trigger"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Options    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Options"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Options"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Send message before schedule is triggered"; Value = ""; }) > $Null    
     
                                If($RDSSChedule.Messages.Count -gt 0)    
                                {    
                                        ForEach($Item in $RDSSChedule.Messages)    
                                        {    
                                                Switch ($Item.SendMsgSecs)    
                                                {    
                                                        900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}    
                                                        1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}    
                                                        2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}    
                                                        3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}    
                                                        7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}    
                                                        10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}    
                                                        Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}    
                                                }    
                                                    
                                                $ScriptInformation.Add(@{Data = "Enabled"; Value = $Item.Enabled.ToString(); }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Body"; Value = $Item.Message; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Title"; Value = $Item.MessageTitle; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Time"; Value = $MsgTime; }) > $Null    
                                        }    
                                }    
     
                                If($Action -ne "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Enable Drain Mode"; Value = $RDSSchedule.DrainMode.ToString(); }) > $Null    
                                }    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Force server reboot after"; Value = $ForceRebootTime; }) > $Null    
                                }    
                                If($Action -like "Reboot*")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Enforce schedule for currently inactive RD Session Host"; Value = $RDSSchedule.EnforceOnInactive.ToString(); }) > $Null    
                                }    
                                If($Action -eq "Disable")    
                                {    
                                        $ScriptInformation.Add(@{Data = "On disable"; Value = $OnDisable; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Send message before schedule is triggered"    
                                    
                                If($RDSSChedule.Messages.Count -gt 0)    
                                {    
                                        ForEach($Item in $RDSSChedule.Messages)    
                                        {    
                                                Switch ($Item.SendMsgSecs)    
                                                {    
                                                        900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}    
                                                        1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}    
                                                        2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}    
                                                        3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}    
                                                        7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}    
                                                        10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}    
                                                        Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}    
                                                }    
                                                    
                                                Line 3 "Enabled`t`t`t`t: " $Item.Enabled.ToString()    
                                                Line 3 "Body`t`t`t`t: " $Item.Message    
                                                Line 3 "Title`t`t`t`t: " $Item.MessageTitle    
                                                Line 3 "Time`t`t`t`t: " $MsgTime    
                                        }    
                                }    
     
                                If($Action -ne "Disable")    
                                {    
                                        Line 3 "Enable Drain Mode`t`t: " $RDSSchedule.DrainMode.ToString()    
                                }    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        Line 3 "Force server reboot after`t: " $ForceRebootTime    
                                }    
                                If($Action -like "Reboot*")    
                                {    
                                        Line 3 "Enforce schedule for currently"    
                                        Line 3 "inactive RD Session Host`t: " $RDSSchedule.EnforceOnInactive.ToString()    
                                }    
                                If($Action -eq "Disable")    
                                {    
                                        Line 3 "On disable`t`t`t: " $OnDisable    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Send message before schedule is triggered",($Script:htmlsb),"",$htmlwhite)    
                                    
                                If($RDSSChedule.Messages.Count -gt 0)    
                                {    
                                        ForEach($Item in $RDSSChedule.Messages)    
                                        {    
                                                Switch ($Item.SendMsgSecs)    
                                                {    
                                                        900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}    
                                                        1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}    
                                                        2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}    
                                                        3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}    
                                                        7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}    
                                                        10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}    
                                                        Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}    
                                                }    
                                                    
                                                $rowdata += @(,("Enabled",($Script:htmlsb),$Item.Enabled.ToString(),$htmlwhite))    
                                                $rowdata += @(,("Body",($Script:htmlsb),$Item.Message,$htmlwhite))    
                                                $rowdata += @(,("Title",($Script:htmlsb),$Item.MessageTitle,$htmlwhite))    
                                                $rowdata += @(,("Time",($Script:htmlsb),$MsgTime,$htmlwhite))    
                                        }    
                                }    
     
                                If($Action -ne "Disable")    
                                {    
                                        $rowdata += @(,("Enable Drain Mode",($Script:htmlsb),$RDSSchedule.DrainMode.ToString(),$htmlwhite))    
                                }    
                                If($Action -eq "Reboot - Drain Mode")    
                                {    
                                        $rowdata += @(,("Force server reboot after",($Script:htmlsb),$ForceRebootTime,$htmlwhite))    
                                }    
                                If($Action -like "Reboot*")    
                                {    
                                        $rowdata += @(,("Enforce schedule for currently inactive RD Session Host",($Script:htmlsb),$RDSSchedule.EnforceOnInactive.ToString(),$htmlwhite))    
                                }    
                                If($Action -eq "Disable")    
                                {    
                                        $rowdata += @(,("On disable",($Script:htmlsb),$OnDisable,$htmlwhite))    
                                }    
     
                                $msg = "Options"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
        }    
     
        $VDIHosts = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve VDI for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve VDI for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $VDIHosts)    
        {    
                Write-Host "    
                No VDI retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No VDI retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No VDI retrieved for Site $($Site.Name)"                                   Line 2 "Provider`t`t: " $TemplateProviderName
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No VDI retrieved for Site $($Site.Name)"    
                }    
        }    
        Else    
        {    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 2 0 "VDI"    
                }    
                If($Text)    
                {    
                        Line 1 "VDI"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "VDI"    
                }    
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput VDI"    
                ForEach($VDIHost in $VDIHosts)    
                {    
                        $VDIHostStatus = Get-RASProviderStatus -Id $VDIHost.Id -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)`    
                                "    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve VDI Host Status for VDI Host $($VDIHost.Id)"    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $VDIHostStatus)    
                        {    
                                Write-Host "    
                                No VDI Host Status retrieved for VDI Host $($VDIHost.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"    
                                }    
                                If($Text)    
                                {    
                                        Line 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 0 0 "No VDI Host Status retrieved for VDI Host $($VDIHost.Id)"    
                                }    
                        }    
                        Else    
                        {    
                                $FullProviderStatus = GetRASStatus $VDIHostStatus.AgentState    
     
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 3 0 "Providers"    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Providers"    
                                }    
                                If($HTML)    
                                {    
                                        WriteHTMLLine 3 0 "Providers"    
                                }    
     
                                $VDIType = GetVDIType $VDIHost.Type    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Provider"; Value = $VDIHost.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VDI Agent"; Value = $VDIHost.VDIAgent; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $FullProviderStatus; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Direct address"; Value = $VDIHost.DirectAddress; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $VDIHostStatus.LogLevel; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDIHost.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDIHost.TimeLastMod.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $VDIHost.AdminCreate; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $VDIHost.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $VDIHost.Id.ToString(); }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Provider`t`t: " $VDIHost.Server                                   Line 2 "Provider type`t`t: " $TemplateProviderType
                                        Line 3 "Type`t`t`t: " $VDIType    
                                        Line 3 "VDI Agent`t`t: " $VDIHost.VDIAgent    
                                        Line 3 "Status`t`t`t: " $FullProviderStatus    
                                        Line 3 "Direct address`t`t: " $VDIHost.DirectAddress    
                                        Line 3 "Description`t`t: " $VDIHost.Description    
                                        Line 3 "Log level`t`t: " $VDIHostStatus.LogLevel    
                                        Line 3 "Last modification by`t: " $VDIHost.AdminLastMod                                   Line 2 "Last modification by`t: " $RDSTemplate.AdminLastMod
                                        Line 3 "Modified on`t`t: " $VDIHost.TimeLastMod.ToString()                                   Line 2 "Modified on`t`t: " $RDSTemplate.TimeLastMod.ToString()
                                        Line 3 "Created by`t`t: " $VDIHost.AdminCreate                                   Line 2 "Created by`t`t: " $RDSTemplate.AdminCreate
                                        Line 3 "Created on`t`t: " $VDIHost.TimeCreate.ToString()                                   Line 2 "Created on`t`t: " $RDSTemplate.TimeCreate.ToString()
                                        Line 3 "ID`t`t`t: " $VDIHost.Id.ToString()                                   Line 2 "ID`t`t`t: " $RDSTemplate.Id.ToString()
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                        $rowdata = @()                                   $rowdata = @()
                                        $columnHeaders = @("Provider",($Script:htmlsb),$VDIHost.Server,$htmlwhite)                                   $columnHeaders = @("Name",($Script:htmlsb),$RDSTemplate.Name,$htmlwhite)
                                        $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))                                   #$rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("VDI Agent",($Script:htmlsb),$VDIHost.VDIAgent,$htmlwhite))                                   $rowdata += @(,("Power state",($Script:htmlsb),$TemplatePowerState,$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$FullProviderStatus,$htmlwhite))                                   #$rowdata += @(,("Agent status",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("Direct address",($Script:htmlsb),$VDIHost.DirectAddress,$htmlwhite))                                   #$rowdata += @(,("Distribution",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("Description",($Script:htmlsb),$VDIHost.Description,$htmlwhite))                                   $rowdata += @(,("Provider",($Script:htmlsb),$TemplateProviderName,$htmlwhite))
                                        $rowdata += @(,("Log level",($Script:htmlsb),$VDIHostStatus.LogLevel,$htmlwhite))                                   $rowdata += @(,("Provider type",($Script:htmlsb),$TemplateProviderType,$htmlwhite))
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $VDIHost.AdminLastMod,$htmlwhite))                                   $rowdata += @(,("Last modification by",($Script:htmlsb), $RDSTemplate.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $VDIHost.TimeLastMod.ToString(),$htmlwhite))                                   $rowdata += @(,("Modified on",($Script:htmlsb), $RDSTemplate.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $VDIHost.AdminCreate,$htmlwhite))                                   $rowdata += @(,("Created by",($Script:htmlsb), $RDSTemplate.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $VDIHost.TimeCreate.ToString(),$htmlwhite))                                   $rowdata += @(,("Created on",($Script:htmlsb), $RDSTemplate.TimeCreate.ToString(),$htmlwhite))
                                        $rowdata += @(,("Id",($Script:htmlsb),$VDIHost.Id.ToString(),$htmlwhite))                                   $rowdata += @(,("Id",($Script:htmlsb),$RDSTemplate.Id.ToString(),$htmlwhite))
 
                                        $msg = "" <>                                 $msg = ""
                                        $columnWidths = @("200","275")                                   $columnWidths = @("200","275")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                }    
 
                                Line 3 "General" <>                                 Line 2 "General"
 
                        $HostPA = Get-RASPA -Id $VDIHost.PreferredPAId -EA 0 4>$Null <>                         Switch($RDSTemplate.UnusedVMDurationMins)
                            
                        If($? -and -$Null -ne $HostPA)    
 
                                If($VDIHost.VDIAgent -eq $HostPa.Server) <>                                 0               {$DeleteVMTime = "Never"; Break}
                                {    
                                        $DedicatedVDIAgent = $False    
                                }    
                                Else    
                                {    
                                        $DedicatedVDIAgent = $True                                   5               {$DeleteVMTime = "5 minutes"; Break}
                                    30              {$DeleteVMTime = "30 minutes"; Break}
                                    60              {$DeleteVMTime = "1 hour"; Break}
                                    1440    {$DeleteVMTime = "1 day"; Break}
                                    10080   {$DeleteVMTime = "1 week"; Break}
                                    43200   {$DeleteVMTime = "30 days"; Break}
                                    Default {$DeleteVMTime = "Unable to determine Delete unused guest VMs after: $($RDSTemplate.UnusedVMDurationMins)"; Break}
                                }                           }
                        }                          
                        ElseIf($? -and $Null -eq $HostPA)                           Switch($RDSTemplate.CloneMethod)
 
                                $DedicatedVDIAgent = $False <>                                 "LinkedClone"   {$CloneMethod = "Create a linked clone"; Break}
                                    "FullClone"             {$CloneMethod = "Create a full clone"; Break}
                                    Default                 {$CloneMethod = "Unable to determine Clone method: $($RDSTemplate.CloneMethod)"; Break}
 
                        Else <>  
                        {    
                                $DedicatedVDIAgent = $False    
                        }    
                            
 
                                $ScriptInformation.Add(@{Data = "Enable provider in site"; Value = $VDIHost.Enabled.ToString(); }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null                                   $ScriptInformation.Add(@{Data = "Template name"; Value = $RDSTemplate.Name; }) > $Null
                                If($VDIType -eq "Azure")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $VDIHost.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $RDSTemplate.MaxVMs.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Subscription details"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $RDSTemplate.PreCreatedVMs.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Authentication URL"; Value = $VDIHost.AzureInfo.AuthenticationURL; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Management URL"; Value = $VDIHost.AzureInfo.ManagementURL; }) > $Null                                   $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $RDSTemplate.VMNameFormat; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     Resource URI"; Value = $VDIHost.AzureInfo.ResourceURI; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $VDIHost.AzureInfo.TenantID; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $VDIHost.AzureInfo.SubscriptionID; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Host"; Value = $VDIHost.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Port"; Value = $VDIHost.VDIPort.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $VDIHost.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Guest VM state after the preparation"; Value = "Can't find"; }) > $Null
                                }    
                                $ScriptInformation.Add(@{Data = "Dedicated VDI Agent"; Value = $DedicatedVDIAgent.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMTime; }) > $Null
                                If($DedicatedVDIAgent)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Agent address"; Value = $VDIHost.VDIAgent; }) > $Null                                   $ScriptInformation.Add(@{Data = "Clone method"; Value = $CloneMethod; }) > $Null
                                }    
 
                                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
 
  <>                                 Line 3 "Template name`t`t`t`t`t: " $RDSTemplate.Name
                                    Line 3 "Maximum guest VMs`t`t`t`t: " $RDSTemplate.MaxVMs.ToString()
                                Line 4 "Enable provider in site`t`t: " $VDIHost.Enabled.ToString()                                   Line 3 "Keep available buffer`t`t`t`t: " $RDSTemplate.PreCreatedVMs.ToString()
                                Line 4 "Type`t`t`t`t: " $VDIType    
                                If($VDIType -eq "Azure")    
                                {    
                                        Line 4 "Name`t`t`t`t: " $VDIHost.Server                                   Line 3 "Guest VM name`t`t`t`t`t: " $RDSTemplate.VMNameFormat
                                        Line 4 "Description`t`t`t: " $VDIHost.Description                                   Line 3 "Guest VM state after the preparation`t: " "Can't find"
                                        Line 4 "Subscription details`t`t: "     
                                        Line 5 "Authentication URL: " $VDIHost.AzureInfo.AuthenticationURL    
                                        Line 5 "Management URL`t  : " $VDIHost.AzureInfo.ManagementURL    
                                        Line 5 "Resource URI`t  : " $VDIHost.AzureInfo.ResourceURI    
                                        Line 4 "Tenant ID`t`t`t: " $VDIHost.AzureInfo.TenantID    
                                        Line 4 "Subscription ID`t`t`t: " $VDIHost.AzureInfo.SubscriptionID    
                                }    
                                Else    
                                {    
                                        Line 4 "Host`t`t`t`t: " $VDIHost.Server    
                                        Line 4 "Port`t`t`t`t: " $VDIHost.VDIPort.ToString()    
                                        Line 4 "Description`t`t`t: " $VDIHost.Description    
                                }    
                                Line 4 "Dedicated VDI Agent`t`t: " $DedicatedVDIAgent.ToString()    
                                If($DedicatedVDIAgent)    
                                {    
                                        Line 4 "Agent address`t`t`t: " $VDIHost.VDIAgent                                   Line 3 "Delete unused guest VMs after`t`t`t: " $DeleteVMTime
                                }                                   Line 3 "Clone method`t`t`t`t`t: " $CloneMethod
 
                                $columnHeaders = @("Enable provider in site",($Script:htmlsb),$VDIHost.Enabled.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Template name",($Script:htmlsb),$RDSTemplate.Name,$htmlwhite)
                                $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))    
                                If($VDIType -eq "Azure")    
                                {    
                                        $rowdata += @(,( "Name",($Script:htmlsb), $VDIHost.Server,$htmlwhite))                                   $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$RDSTemplate.MaxVMs.ToString(),$htmlwhite))
                                        $rowdata += @(,( "Description",($Script:htmlsb), $VDIHost.Description,$htmlwhite))    
                                        $rowdata += @(,( "Subscription details",($Script:htmlsb), "",$htmlwhite))                                   $rowdata += @(,("Keep available buffer",($Script:htmlsb),$RDSTemplate.PreCreatedVMs.ToString(),$htmlwhite))
                                        $rowdata += @(,( "     Authentication URL",($Script:htmlsb), $VDIHost.AzureInfo.AuthenticationURL,$htmlwhite))    
                                        $rowdata += @(,( "     Management URL",($Script:htmlsb), $VDIHost.AzureInfo.ManagementURL,$htmlwhite))                                   $rowdata += @(,("Guest VM name",($Script:htmlsb),$RDSTemplate.VMNameFormat,$htmlwhite))
                                        $rowdata += @(,( "     Resource URI",($Script:htmlsb), $VDIHost.AzureInfo.ResourceURI,$htmlwhite))    
                                        $rowdata += @(,( "Tenant ID",($Script:htmlsb), $VDIHost.AzureInfo.TenantID,$htmlwhite))    
                                        $rowdata += @(,( "Subscription ID",($Script:htmlsb), $VDIHost.AzureInfo.SubscriptionID,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Host",($Script:htmlsb),$VDIHost.Server,$htmlwhite))    
                                        $rowdata += @(,("Port",($Script:htmlsb),$VDIHost.VDIPort.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Description",($Script:htmlsb),$VDIHost.Description,$htmlwhite))                                   $rowdata += @(,("Guest VM state after the preparation",($Script:htmlsb),"Can't find",$htmlwhite))
                                }    
                                $rowdata += @(,("Dedicated VDI Agent",($Script:htmlsb),$DedicatedVDIAgent.ToString(),$htmlwhite))                                   $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMTime,$htmlwhite))
                                If($DedicatedVDIAgent)    
                                {    
                                        $rowdata += @(,("Agent address",($Script:htmlsb),$VDIHost.VDIAgent,$htmlwhite))                                   $rowdata += @(,("Clone method",($Script:htmlsb),$CloneMethod,$htmlwhite))
                                }    
 
                                $columnWidths = @("200","275") <>                                 $columnWidths = @("300","275")
 
                        #Credentials <>                         #Advanced
 
                                WriteWordLine 4 0 "Credentials" <>                                 WriteWordLine 4 0 "Advanced"
 
                                Line 3 "Credentials" <>                                 Line 2 "Advanced"
 
                                If($VDIType -eq "Azure") <>                                 $ScriptInformation.Add(@{Data = "Folder"; Value = $RDSTemplate.FolderName; }) > $Null
                                {                                   $ScriptInformation.Add(@{Data = "Resource pool"; Value = $RDSTemplate.NativePoolName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Application ID"; Value = $VDIHost.VDIUsername; }) > $Null                                   $ScriptInformation.Add(@{Data = "Physical Host"; Value = $RDSTemplate.PhysicalHostName; }) > $Null
                                }                                   $ScriptInformation.Add(@{Data = "Enable hardware acceleration graphics licensing support"; Value = $RDSTemplate.HWGPU.ToString(); }) > $Null
                                Else                                   #$ScriptInformation.Add(@{Data = "Use a separate network interface for LAN access"; Value = "Can't find"; }) > $Null
                                {                                   #$ScriptInformation.Add(@{Data = "Specify management network details"; Value = ""; }) > $Null
                                    #$ScriptInformation.Add(@{Data = "     Address"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Username"; Value = $VDIHost.VDIUsername; }) > $Null                                   #$ScriptInformation.Add(@{Data = "     Subnet mask"; Value = ""; }) > $Null
                                }    
 
                                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
 
                                If($VDIType -eq "Azure") <>                                 Line 3 "Folder`t`t`t`t: " $RDSTemplate.FolderName
                                {                                   Line 3 "Resource pool`t`t`t: " $RDSTemplate.NativePoolName
                                    Line 3 "Physical Host`t`t`t: " $RDSTemplate.PhysicalHostName
                                    Line 3 "Enable hardware acceleration "
                                        Line 4 "Application ID: " $VDIHost.VDIUsername                                   Line 3 "graphics licensing support`t: " $RDSTemplate.HWGPU.ToString()
                                }                                   #Line 3 "Use a separate network interface for LAN access: " "Can't find"
                                Else                                   #Line 3 "Specify management network details:"
                                {    
                                        Line 4 "Username`t`t`t: " $VDIHost.VDIUsername                                   #Line 4 "Address`t`t`t: " $DeleteVMTime
                                }                                   #Line 4 "Subnet mask`t`t: " $CloneMethod
 
                                If($VDIType -eq "Azure") <>  
                                {    
                                        $columnHeaders = @("Application ID",($Script:htmlsb),$VDIHost.VDIUsername,$htmlwhite)                                   $columnHeaders = @("Folder",($Script:htmlsb),$RDSTemplate.FolderName,$htmlwhite)
                                }                                   $rowdata += @(,("Resource pool",($Script:htmlsb),$RDSTemplate.NativePoolName,$htmlwhite))
                                Else                                   $rowdata += @(,("Physical Host",($Script:htmlsb),$RDSTemplate.PhysicalHostName,$htmlwhite))
                                {                                   $rowdata += @(,("Enable hardware acceleration graphics licensing support",($Script:htmlsb),$RDSTemplate.HWGPU.ToString(),$htmlwhite))
                                    #$rowdata += @(,("Use a separate network interface for LAN access",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $columnHeaders = @("Username",($Script:htmlsb),$VDIHost.VDIUsername,$htmlwhite)                                   #$rowdata += @(,("Specify management network details",($Script:htmlsb),"",$htmlwhite))
                                }                                   #$rowdata += @(,("     Address",($Script:htmlsb),"",$htmlwhite))
                                    #$rowdata += @(,("     Subnet mask",($Script:htmlsb),"",$htmlwhite))
 
                                $msg = "Credentials" <>                                 $msg = "Advanced"
                                $columnWidths = @("200","275")                                   $columnWidths = @("300","275")
 
  <>                         
                        #Agent Settings                           #Preparation
 
                                WriteWordLine 4 0 "Agent settings" <>                                 WriteWordLine 4 0 "Preparation"
 
                                Line 3 "Agent settings" <>                                 Line 2 "Preparation"
 
                        <#Switch ($VDIHost.DragAndDropMode) +-  
                        {    
                                "Bidirectional"         {$VDIHostDragAndDrop = "Bidirectional"; Break}    
                                "Disabled"                      {$VDIHostDragAndDrop = "Disabled"; Break}    
                                "ClientToServer"        {$VDIHostDragAndDrop = "Client to server only"; Break}    
                                "ServerToClient"        {$VDIHostDragAndDrop = "Server to client only"; Break}    
                                Default                         {$VDIHostDragAndDrop = "Unable to determine Drag and drop: $($VDIHost.DragAndDropMode)"; Break}    
                        }#>    
     
                        Switch ($VDIHost.FileTransferMode)    
                        {    
                                "Bidirectional"         {$VDIHostFileTransferMode = "Bidirectional"; Break}    
                                "Disabled"                      {$VDIHostFileTransferMode = "Disabled"; Break}    
                                "ClientToServer"        {$VDIHostFileTransferMode = "Client to server only"; Break}    
                                "ServerToClient"        {$VDIHostFileTransferMode = "Server to client only"; Break}    
                                Default                         {$VDIHostFileTransferMode = "Unable to determine File Transfer mode: $($VDIHost.FileTransferMode)"; Break}    
                        }    
     
                        If($VDIHost.FileTransferLocation -eq "")    
                        {    
                                $VDIHostFileTransferLocation = "Default download location"    
                        }    
                        Else    
                        {    
                                $VDIHostFileTransferLocation = $VDIHostHost.FileTransferLocation    
                        }    
     
 
                                $ScriptInformation.Add(@{Data = "Allow Client URL/Mail Redirection"; Value = $VDIHost.AllowURLAndMailRedirection.ToString(); }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Support Windows Shell URL namespace objects"; Value = $VDIHost.SupportShellURLNamespaceObjects.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Image preparation tool"; Value = $RDSTemplate.ImagePrepTool.ToString(); }) > $Null
                                #$ScriptInformation.Add(@{Data = "Drag and drop"; Value = $VDIHostDragAndDrop; }) > $Null                                   $ScriptInformation.Add(@{Data = "Computer name"; Value = $RDSTemplate.ComputerName; }) > $Null
                                $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $VDIHostStatus.PreferredPA; }) > $Null                                   $ScriptInformation.Add(@{Data = "Owner name"; Value = $RDSTemplate.OwnerName; }) > $Null
                                $ScriptInformation.Add(@{Data = "Allow file transfer command (HTML5 and Chrome clients)"; Value = $VDIHost.AllowFileTransfer.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Organization"; Value = $RDSTemplate.Organization; }) > $Null
                                $ScriptInformation.Add(@{Data = "Configure File Transfer"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Active Directory domain"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Direction"; Value = $VDIHostFileTransferMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Domain"; Value = $RDSTemplate.Domain; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Location"; Value = $VDIHostFileTransferLocation; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Administrator"; Value = $RDSTemplate.Administrator; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Do not allow to change location"; Value = $VDIHost.FileTransferLockLocation.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Target OU"; Value = $RDSTemplate.DomainOrgUnit; }) > $Null
                                $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $VDIHost.EnableDriveRedirectionCache.ToString(); }) > $Null    
 
                                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
 
                                Line 4 "Allow Client URL/Mail Redirection`t`t`t: " $VDIHost.AllowURLAndMailRedirection.ToString() <>  
                                Line 4 "Support Windows Shell URL namespace objects`t`t: " $VDIHost.SupportShellURLNamespaceObjects.ToString()                                   Line 3 "Image preparation tool`t: " $RDSTemplate.ImagePrepTool.ToString()
                                #Line 4 "Drag and drop`t`t`t`t`t`t: " $VDIHostDragAndDrop                                   Line 3 "Computer name`t`t: " $RDSTemplate.ComputerName
                                Line 4 "Preferred Publishing Agent`t`t`t`t: " $VDIHostStatus.PreferredPA                                   Line 3 "Owner name`t`t: " $RDSTemplate.OwnerName
                                Line 4 "Allow file transfer command (HTML5 and Chrome clients)`t: " $VDIHost.AllowFileTransfer.ToString()                                   Line 3 "Organization`t`t: " $RDSTemplate.Organization
                                Line 4 "Configure File Transfer"                                   Line 3 "Active Directory domain"
                                Line 5 "Direction`t`t`t: " $VDIHostFileTransferMode                                   Line 4 "Domain`t`t: " $RDSTemplate.Domain
                                Line 5 "Location`t`t`t: " $VDIHostFileTransferLocation                                   Line 4 "Administrator`t: " $RDSTemplate.Administrator
                                Line 5 "Do not allow to change location`t: " $VDIHost.FileTransferLockLocation.ToString()                                   Line 4 "Target OU`t: " $RDSTemplate.DomainOrgUnit
                                Line 4 "Enable drive redirection cache`t`t`t`t: " $VDIHost.EnableDriveRedirectionCache.ToString()    
 
                                $columnHeaders = @("Allow Client URL/Mail Redirection",($Script:htmlsb),$VDIHost.AllowURLAndMailRedirection.ToString(),$htmlwhite) <>  
                                $rowdata += @(,("Support Windows Shell URL namespace objects",($Script:htmlsb),$VDIHost.SupportShellURLNamespaceObjects.ToString(),$htmlwhite))                                   $columnHeaders = @("Image preparation tool",($Script:htmlsb),$RDSTemplate.ImagePrepTool.ToString(),$htmlwhite)
                                #$rowdata += @(,("Drag and drop",($Script:htmlsb),$VDIHostDragAndDrop,$htmlwhite))                                   $rowdata += @(,("Computer name",($Script:htmlsb),$RDSTemplate.ComputerName,$htmlwhite))
                                $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$VDIHostStatus.PreferredPA,$htmlwhite))                                   $rowdata += @(,("Owner name",($Script:htmlsb),$RDSTemplate.OwnerName,$htmlwhite))
                                $rowdata += @(,("Allow file transfer command (HTML5 and Chrome clients)",($Script:htmlsb),$VDIHost.AllowFileTransfer.ToString(),$htmlwhite))                                   $rowdata += @(,("Organization",($Script:htmlsb),$RDSTemplate.Organization,$htmlwhite))
                                $rowdata += @(,("Configure File Transfer",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Active Directory domain",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("     Direction",($Script:htmlsb),$VDIHostFileTransferMode,$htmlwhite))                                   $rowdata += @(,("     Domain",($Script:htmlsb),$RDSTemplate.Domain,$htmlwhite))
                                $rowdata += @(,("     Location",($Script:htmlsb),$VDIHostFileTransferLocation,$htmlwhite))                                   $rowdata += @(,("     Administrator",($Script:htmlsb),$RDSTemplate.Administrator,$htmlwhite))
                                $rowdata += @(,("     Do not allow to change location",($Script:htmlsb),$VDIHost.FileTransferLockLocation.ToString(),$htmlwhite))                                   $rowdata += @(,("     Target OU",($Script:htmlsb),$RDSTemplate.DomainOrgUnit,$htmlwhite))
                                $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$VDIHost.EnableDriveRedirectionCache.ToString(),$htmlwhite))    
 
                                $msg = "Agent settings" <>                                 $msg = "Preparation"
                                $columnWidths = @("200","275")                                   $columnWidths = @("300","275")
 
  <>                         
                        #RDP Printer                           #Optimization
 
                                WriteWordLine 4 0 "RDP printer" <>                                 WriteWordLine 4 0 "Optimization"
 
                                Line 3 "RDP printer" <>                                 Line 2 "Optimization"
 
                         <>  
                        Switch ($VDIHost.PrinterNameFormat)                           If($RDSTemplate.InheritDefaultOptimizationSettings)
 
                                "PrnFormat_PRN_CMP_SES" {$VDIPrinterNameFormat = "Printername (from Computername) in Session no."; Break} <>                                 #do we inherit site defaults?
                                "PrnFormat_SES_CMP_PRN" {$VDIPrinterNameFormat = "Session no. (Computername from) Printername"; Break}                                   #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/
                                "PrnFormat_PRN_REDSES"  {$VDIPrinterNameFormat = "Printername (redirected Session no.)"; Break}                                   #for translating the User SID to the AD user name
                                Default                                 {$VDIPrinterNameFormat = "Unable to determine RDP Printer Name Format: $($VDIHost.PrinterNameFormat)"; Break}                                   #yes we do, get the default settings for the Site
                        }                                   #use the Site default settings
                                    $RDSDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                                          
                        $VDIRemoveSessionNumberFromPrinter = $VDIHost.RemoveSessionNumberFromPrinterName.ToString()                                   If($? -and $Null -ne $RDSDefaults)
     
                        If($MSWord -or $PDF)    
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $OPTEnableOptimization            = $RDSDefaults.Optimization.EnableOptimization.ToString()
                                $ScriptInformation.Add(@{Data = "RDP Printer Name Format"; Value = $VDIPrinterNameFormat; }) > $Null                                           $OPTOptimizationType              = $RDSDefaults.Optimization.OptimizationType.ToString()
                                            $OPTWindowsDefenderATPEnabled     = $RDSDefaults.Optimization.WindowsDefenderATPEnabled.ToString()    
                                $ScriptInformation.Add(@{Data = "Remove session number from printer name"; Value = $VDIRemoveSessionNumberFromPrinter; }) > $Null                                           $OPTWindowsComponentsEnabled      = $RDSDefaults.Optimization.WindowsComponentsEnabled.ToString()
                                            $OPTWindowsServicesEnabled        = $RDSDefaults.Optimization.WindowsServicesEnabled.ToString()
                                $Table = AddWordTable -Hashtable $ScriptInformation `                                           $OPTWinodwsScheduledTasksEnabled  = $RDSDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $OPTWindowsAdvancedOptionsEnabled = $RDSDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 4 "RDP Printer Name Format`t`t`t`t: " $VDIPrinterNameFormat    
                                Line 4 "Remove session number from printer name`t`t: " $VDIRemoveSessionNumberFromPrinter    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("RDP Printer Name Format",($Script:htmlsb),$VDIPrinterNameFormat,$htmlwhite)                                           $OPTNetworkPerformanceEnabled     = $RDSDefaults.Optimization.NetworkPerformanceEnabled.ToString()
                                $rowdata += @(,("Remove session number from printer name",($Script:htmlsb),$VDIRemoveSessionNumberFromPrinter,$htmlwhite))    
     
                                $msg = "RDP printer"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
                    
                #Pools    
                    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 3 0 "Pools"    
                }    
                If($Text)    
                {    
                        Line 2 "Pools"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 3 0 "Pools"    
                }    
                    
                If($MSWord -or $PDF)    
                {    
                        $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null    
                        If($? -and $Null -ne $VDIPools)    
                        {    
                                ForEach($VDIPool in $VDIPools)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                           $OPTRegistryEnabled               = $RDSDefaults.Optimization.RegistryEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "Pools"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "  Name"; Value = $VDIPool.Name; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "  Last modification by"; Value = $VDIPool.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "  Modified on"; Value = $VDIPool.TimeLastMod.ToString(); }) > $Null                                           $OPTVisualEffectsEnabled          = $RDSDefaults.Optimization.VisualEffectsEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "  Created by"; Value = $VDIPool.AdminCreate; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "  Created on"; Value = $VDIPool.TimeCreate.ToString(); }) > $Null                                           $OPTDiskCleanupEnabled            = $RDSDefaults.Optimization.DiskCleanupEnabled.ToString()
                                            
                                        ForEach($Item in $VDIPool.Members)    
                                        {    
                                                $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $VDIPoolMembers)    
                                                {    
                                                        $cnt = -1    
                                                        ForEach($VDIPoolMember in $VDIPoolMembers)    
                                                        {    
                                                                Switch($VDIPoolMember.Type)    
                                                                {    
                                                                        "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}    
                                                                        "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}    
                                                                        "GUEST"                                 {$MemberType = "Guest VM"; Break}    
                                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}    
                                                                        "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}    
                                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}    
                                                                }    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "    Members"; Value = "Name: $($VDIPoolMember.Name) Type: $MemberType"; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Name: $($VDIPoolMember.Name) Type: $MemberType"; }) > $Null    
                                                                }    
                                                        }    
                                                }    
                                                ElseIf($? -and $Null -eq $VDIPoolMembers)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "    Members"; Value = "None found"; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "    Members"; Value = "Unable to retrieve"; }) > $Null    
                                                }    
                                        }    
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $OPTCustomScriptEnabled           = $RDSDefaults.Optimization.CustomScriptEnabled.ToString()
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
 
                        } <>  
                        ElseIf($? -and $Null -eq $VDIPools)    
                        {    
                                WriteWordLine 0 0 "No VDI Pools found for Site $($Site.Name)"    
                        }    
                        Else                                   Else
                        {    
                                WriteWordLine 0 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"    
                        }    
                        WriteWordLine 0 0 ""    
                }    
                If($Text)    
                {    
                        $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null    
                        If($? -and $Null -ne $VDIPools)    
                        {    
                                ForEach($VDIPool in $VDIPools)    
 
                                        Line 3 "Pools" <>                                         #unable to retrieve default, use built-in default values
                                        Line 4 "Name`t`t: " $VDIPool.Name                                           $OPTEnableOptimization            = "False"
                                        Line 4 "Last modification by`t: " $VDIPool.AdminLastMod                                           $OPTOptimizationType              = ""
                                        Line 4 "Modified on`t`t: " $VDIPool.TimeLastMod.ToString()                                           $OPTWindowsDefenderATPEnabled     = "False"
                                        Line 4 "Created by`t`t: " $VDIPool.AdminCreate                                           $OPTWindowsComponentsEnabled      = "False"
                                        Line 4 "Created on`t`t: " $VDIPool.TimeCreate.ToString()                                           $OPTWindowsServicesEnabled        = "False"
                                                                                  $OPTWinodwsScheduledTasksEnabled  = "False"
                                        ForEach($Item in $VDIPool.Members)                                           $OPTWindowsAdvancedOptionsEnabled = "False"
                                        {    
                                                $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $VDIPoolMembers)    
                                                {    
                                                        $cnt = -1    
                                                        ForEach($VDIPoolMember in $VDIPoolMembers)    
                                                        {    
                                                                Switch($VDIPoolMember.Type)    
                                                                {    
                                                                        "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}    
                                                                        "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}    
                                                                        "GUEST"                                 {$MemberType = "Guest VM"; Break}    
                                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}                                           $OPTNetworkPerformanceEnabled     = "False"
                                                                        "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}    
                                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}    
                                                                }    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        Line 4 "Members`t`t: " "Name: $($VDIPoolMember.Name) Type: $MemberType"    
                                                                }    
                                                                Else    
                                                                {    
                                                                        Line 6 "Name: $($VDIPoolMember.Name) Type: $MemberType"    
                                                                }    
                                                        }    
                                                }    
                                                ElseIf($? -and $Null -eq $VDIPoolMembers)    
                                                {    
                                                        Line 4 "Members`t`t: " "None found"    
                                                }    
                                                Else    
                                                {    
                                                        Line 4 "Members`t`t: " "Unable to retrieve"    
                                                }    
                                        }    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($? -and $Null -eq $VDIPools)    
                        {    
                                Line 0 "No VDI Pools found for Site $($Site.Name)"    
                        }    
                        Else    
                        {    
                                Line 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"    
                        }    
                        Line 0 ""    
                }    
                If($HTML)    
                {    
                        $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null    
                        If($? -and $Null -ne $VDIPools)    
                        {    
                                ForEach($VDIPool in $VDIPools)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Pools",($Script:htmlsb),"",$htmlwhite)    
                                        $rowdata += @(,("  Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite))    
                                        $rowdata += @(,("  Last modification by",($Script:htmlsb), $VDIPool.AdminLastMod,$htmlwhite))    
                                        $rowdata += @(,("  Modified on",($Script:htmlsb), $VDIPool.TimeLastMod.ToString(),$htmlwhite))    
                                        $rowdata += @(,("  Created by",($Script:htmlsb), $VDIPool.AdminCreate,$htmlwhite))    
                                        $rowdata += @(,("  Created on",($Script:htmlsb), $VDIPool.TimeCreate.ToString(),$htmlwhite))    
                                            
                                        ForEach($Item in $VDIPool.Members)    
                                        {    
                                                $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null    
                                                    
                                                If($? -and $Null -ne $VDIPoolMembers)    
                                                {    
                                                        $cnt = -1    
                                                        ForEach($VDIPoolMember in $VDIPoolMembers)    
                                                        {    
                                                                Switch($VDIPoolMember.Type)    
                                                                {    
                                                                        "ALLGUESTINHOST"                {$MemberType = "All Guest VMs in Host"; Break}    
                                                                        "ALLGUESTSONPROVIDER"   {$MemberType = "All Guest VMs on Provider"; Break}    
                                                                        "GUEST"                                 {$MemberType = "Guest VM"; Break}    
                                                                        "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}    
                                                                        "TEMPLATEGUEST"                 {$MemberType = "Template"; Break}    
                                                                        "UNKNOWN"                               {$MemberType = "Unknown"; Break}    
                                                                        Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}    
                                                                }    
                                                                $cnt++    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $rowdata += @(,("    Members",($Script:htmlsb),"Name: $($VDIPoolMember.Name) Type: $MemberType",$htmlwhite))    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $rowdata += @(,("",($Script:htmlsb),"Name: $($VDIPoolMember.Name) Type: $MemberType",$htmlwhite))    
                                                                }    
                                                        }    
                                                }    
                                                ElseIf($? -and $Null -eq $VDIPoolMembers)    
                                                {    
                                                        $rowdata += @(,("    Members",($Script:htmlsb),"None found",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("    Members",($Script:htmlsb),"Unable to retrieve",$htmlwhite))    
                                                }    
                                        }    
     
                                        $msg = ""    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                        ElseIf($? -and $Null -eq $VDIPools)    
                        {    
                                WriteHTMLLine 0 0 "No VDI Pools found for Site $($Site.Name)"    
                        }    
                        Else    
                        {    
                                WriteHTMLLine 0 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"    
                        }    
                        WriteHTMLLine 0 0 ""    
                }    
                    
                #Templates    
                    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 3 0 "Templates"    
                }    
                If($Text)    
                {    
                        Line 2 "Templates"                                           $OPTRegistryEnabled               = "False"
                }                                           $OPTVisualEffectsEnabled          = "False"
                If($HTML)                                           $OPTDiskCleanupEnabled            = "False"
                {    
                        WriteHTMLLine 3 0 "Templates"    
                }    
                    
                $VDITemplates = Get-RASVDITemplate -SiteId $Site.Id -EA 0 4>$Null    
                If($? -and $Null -ne $VDITemplates)    
                {    
                        ForEach($VDITemplate in $VDITemplates)                                           $OPTCustomScriptEnabled           = "False"
                        {    
                                $VDIHost = Get-RASProvider -Id $VDITemplate.ProviderId -EA 0 4>$Null    
                                    
                                If($? -and $null -ne $VDIHost)    
                                {    
                                        $Provider     = $VDIHost.Server    
                                        $ProviderType = GetVDIType $VDIHost.Type    
                                            
                                        #$ProviderStatus = (Get-RASProviderStatus -Id $VDITemplate.ProviderId -EA 0 4>$Null)     
 
                                ElseIf($? -$Null -eq $VDIHost) <>  
                                {    
                                        $Provider       = "No Provider found"    
                                        $ProviderType   = "Unknown"    
                                        #$ProviderStatus = "Unknown"    
                                }                           }
                                Else                           Else
                                {                           {
                                        $Provider       = "Unable to retrieve Provider with an ID of $($VDITemplate.ProviderId)"    
                                        $ProviderType   = "Unknown"    
                                        #$ProviderStatus = "Unknown"                                   #we don't inherit
                                }                                   #get the settings for the template
 
                                If($MSWord -or $PDF) <>                                 $OPTEnableOptimization            = $RDSTemplate.Optimization.EnableOptimization.ToString()
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $VDITemplate.Name; }) > $Null    
                                        #$ScriptInformation.Add(@{Data = "Status"; Value = $ProviderStatus; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Type"; Value = $VDITemplate.TemplateType.ToString(); }) > $Null                                   $OPTOptimizationType              = $RDSTemplate.Optimization.OptimizationType.ToString()
                                        $ScriptInformation.Add(@{Data = "Provider"; Value = $Provider; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Provider Type"; Value = $ProviderType; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDITemplate.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDITemplate.TimeLastMod.ToString(); }) > $Null                                   $OPTWindowsDefenderATPEnabled     = $RDSTemplate.Optimization.WindowsDefenderATPEnabled.ToString() 
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $VDITemplate.AdminCreate; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $VDITemplate.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $VDITemplate.Id.ToString(); }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $OPTWindowsComponentsEnabled      = $RDSTemplate.Optimization.WindowsComponentsEnabled.ToString()
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Name`t`t`t: " $VDITemplate.Name    
                                        #Line 3 "Status`t`t`t: " $ProviderStatus    
                                        Line 3 "Type`t`t`t: " $VDITemplate.TemplateType.ToString()    
                                        Line 3 "Provider`t`t: " $Provider    
                                        Line 3 "Provider Type`t`t: " $ProviderType    
                                        Line 3 "Last modification by`t: " $VDITemplate.AdminLastMod    
                                        Line 3 "Modified on`t`t: " $VDITemplate.TimeLastMod.ToString()    
                                        Line 3 "Created by`t`t: " $VDITemplate.AdminCreate    
                                        Line 3 "Created on`t`t: " $VDITemplate.TimeCreate.ToString()    
                                        Line 3 "ID`t`t`t: " $VDITemplate.Id.ToString()    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Name",($Script:htmlsb),$VDITemplate.Name,$htmlwhite)    
                                        #$rowdata += @(,("Status",($Script:htmlsb),$ProviderStatus,$htmlwhite))    
                                        $rowdata += @(,("Type",($Script:htmlsb),$VDITemplate.TemplateType.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Provider",($Script:htmlsb),$Provider,$htmlwhite))    
                                        $rowdata += @(,("Provider type",($Script:htmlsb),$ProviderType,$htmlwhite))    
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $VDITemplate.AdminLastMod,$htmlwhite))    
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $VDITemplate.TimeLastMod.ToString(),$htmlwhite))                                   $OPTWindowsServicesEnabled        = $RDSTemplate.Optimization.WindowsServicesEnabled.ToString()
                                        $rowdata += @(,("Created by",($Script:htmlsb), $VDITemplate.AdminCreate,$htmlwhite))                                   $OPTWinodwsScheduledTasksEnabled  = $RDSTemplate.Optimization.WindowsScheduledTasksEnabled.ToString()
                                    $OPTWindowsAdvancedOptionsEnabled = $RDSTemplate.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                        $rowdata += @(,("Created on",($Script:htmlsb), $VDITemplate.TimeCreate.ToString(),$htmlwhite))                                   $OPTNetworkPerformanceEnabled     = $RDSTemplate.Optimization.NetworkPerformanceEnabled.ToString()
                                        $rowdata += @(,("Id",($Script:htmlsb),$VDITemplate.Id.ToString(),$htmlwhite))    
     
                                        $msg = ""    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                #Properties    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "General"    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "General"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                Switch ($VDITemplate.UnusedGuestDurationMins)    
                                {    
                                        0               {$DeleteVMsTime = "Never"; Break}    
                                        1440    {$DeleteVMsTime = "1 day"; Break}    
                                        10080   {$DeleteVMsTime = "1 week"; Break}    
                                        43200   {$DeleteVMsTime = "30 days"; Break}    
                                        Default {$DeleteVMsTime = "Unable to determine Delete unused guest VMs after: $($VDITemplate.UnusedGuestDurationMins)"; Break}    
                                }    
                                    
                                Switch($VDITemplate.CloneMethod)    
                                {    
                                        "LinkedClone"   {$CloneMethod = "Create a linked clone"; Break}    
                                        "FullClone"             {$CloneMethod = "Create a full clone"; Break}    
                                        Default                 {$CloneMethod = "Unable to determine Clone method: $($VDITemplate.CloneMethod)"; Break}    
                                }    
     
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $OPTRegistryEnabled               = $RDSTemplate.Optimization.RegistryEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "Template name"; Value = $VDITemplate.Name; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $VDITemplate.MaxGuests.ToString(); }) > $Null                                   $OPTVisualEffectsEnabled          = $RDSTemplate.Optimization.VisualEffectsEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $VDITemplate.PreCreatedGuests.ToString(); }) > $Null                                   $OPTDiskCleanupEnabled            = $RDSTemplate.Optimization.DiskCleanupEnabled.ToString()
                                        $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $VDITemplate.GuestNameFormat; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMsTime; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Clone method"; Value = $CloneMethod; }) > $Null    
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                   $OPTCustomScriptEnabled           = $RDSTemplate.Optimization.CustomScriptEnabled.ToString()
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }                           }
                                If($Text)    
                                {    
                                        Line 4 "Template name`t`t`t: " $VDITemplate.Name    
                                        Line 4 "Maximum guest VMs`t`t: " $VDITemplate.MaxGuests.ToString()    
                                        Line 4 "Keep available buffer`t`t: " $VDITemplate.PreCreatedGuests.ToString()    
                                        Line 4 "Guest VM name`t`t`t: " $VDITemplate.GuestNameFormat    
                                        Line 4 "Delete unused guest VMs after`t: " $DeleteVMsTime    
                                        Line 4 "Clone method`t`t`t: " $CloneMethod    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Template name",($Script:htmlsb),$VDITemplate.Name,$htmlwhite)    
                                        $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$VDITemplate.MaxGuests.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Keep available buffer",($Script:htmlsb),$VDITemplate.PreCreatedGuests.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Guest VM name",($Script:htmlsb),$VDITemplate.GuestNameFormat,$htmlwhite))    
                                        $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMsTime,$htmlwhite))    
                                        $rowdata += @(,("Clone method",($Script:htmlsb),$CloneMethod,$htmlwhite))    
 
                                        $msg = "Properties" <>  
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                                    
                                #Advanced    
                                    
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                        WriteWordLine 4 0 "Advanced"    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Advanced"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                        $ScriptInformation.Add(@{Data = "Folder"; Value = $VDITemplate.FolderName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $RDSTemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Resource pool"; Value = $VDITemplate.NativePoolName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Physical Host"; Value = $VDITemplate.PhysicalHostName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 #SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }    
                                If($Text)    
                                {    
                                        Line 4 "Folder`t`t`t`t: " $VDITemplate.FolderName    
                                        Line 4 "Resource pool`t`t`t: " $VDITemplate.NativePoolName    
                                        Line 4 "Physical Host`t`t`t: " $VDITemplate.PhysicalHostName    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Folder",($Script:htmlsb),$VDITemplate.FolderName,$htmlwhite)    
                                        $rowdata += @(,("Resource pool",($Script:htmlsb),$VDITemplate.NativePoolName,$htmlwhite))    
                                        $rowdata += @(,("Physical Host",($Script:htmlsb),$VDITemplate.PhysicalHostName,$htmlwhite))    
 
                                        $msg = "Advanced" <>                                 WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled
                                        $columnWidths = @("200","275")                                   If($OPTWindowsDefenderATPEnabled -eq "True")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                                    
                                #Preparation    
                                    
                                If($MSWord -or $PDF)    
 
                                        WriteWordLine 4 0 "Preparation" +-  
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Preparation"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                If($MSWord -or $PDF)    
                                {    
 
                                        $ScriptInformation.Add(@{Data = "Image preparation tool"; Value = $VDITemplate.ImagePrepTool.ToString(); }) > $Null <>  
                                        $ScriptInformation.Add(@{Data = "Computer name"; Value = $VDITemplate.ComputerName; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Owner name"; Value = $VDITemplate.OwnerName; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Organization"; Value = $VDITemplate.Organization; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Join domain"; Value = $VDITemplate.Domain; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Administrator"; Value = $VDITemplate.Administrator; }) > $Null                                           $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Target OU"; Value = $VDITemplate.DomainOrgUnit; }) > $Null    
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>  
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 4 "Image preparation tool`t`t: " $VDITemplate.ImagePrepTool.ToString()    
                                        Line 4 "Computer name`t`t`t: " $VDITemplate.ComputerName    
                                        Line 4 "Owner name`t`t`t: " $VDITemplate.OwnerName    
                                        Line 4 "Organization`t`t`t: " $VDITemplate.Organization    
                                        Line 4 "Join domain`t`t`t: " $VDITemplate.Domain    
                                        Line 4 "Administrator`t`t`t: " $VDITemplate.Administrator    
                                        Line 4 "Target OU`t`t`t: " $VDITemplate.DomainOrgUnit    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Image preparation tool",($Script:htmlsb),$VDITemplate.ImagePrepTool.ToString(),$htmlwhite)    
                                        $rowdata += @(,("Computer name",($Script:htmlsb),$VDITemplate.ComputerName,$htmlwhite))    
                                        $rowdata += @(,("Owner name",($Script:htmlsb),$VDITemplate.OwnerName,$htmlwhite))    
                                        $rowdata += @(,("Organization",($Script:htmlsb),$VDITemplate.Organization,$htmlwhite))    
                                        $rowdata += @(,("Join domain",($Script:htmlsb),$VDITemplate.Domain,$htmlwhite))    
                                        $rowdata += @(,("Administrator",($Script:htmlsb),$VDITemplate.Administrator,$htmlwhite))    
                                        $rowdata += @(,("Target OU",($Script:htmlsb),$VDITemplate.DomainOrgUnit,$htmlwhite))    
     
                                        $msg = "Preparation"    
                                        $columnWidths = @("200","275")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
     
                                #User Profile    
                                #There is no way to retrieve the settings if "Inherit default settings" is selected.    
                                #There is also no way to retrieve the Site Defaults, which are more than User profile settings    
                                #I will leave this code in but commented out    
                            
                                <#If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "User profile"    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "User profile"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
     
                                If($VDITemplate.InheritDefUserProfileSettings)    
                                {    
                                        #do we inherit site defaults?    
                                        #yes we do, get the default settings for the Site    
                                        #use the Site default settings    
                                            
                                        #Template technology settings do not include UPD, only FSLogix    
                                        $TemplateDefaults = Get-RASRDSDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                            
                                        If($? -and $Null -ne $TemplateDefaults)    
                                        {    
                                                Switch ($TemplateDefaults.Technology)    
                                                {    
                                                        "DoNotManage"                           {$TemplateTechnology = "Do not manage by RAS"; Break}    
                                                        "FSLogixProfileContainer"       {$TemplateTechnology = "FSLogix"; Break}    
                                                        Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($TemplateDefaults.Technology)"; Break}    
                                                }    
                                                    
                                                $FSLogixSettings           = $TemplateDefaults.FSLogix.ProfileContainer    
                                                $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}    
                                                    
                                                Switch($FSLogixDeploymentSettings.InstallType)    
                                                {    
                                                        "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}    
                                                        "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}    
                                                        "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}    
                                                        "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}    
                                                        Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}    
                                                }    
                                                    
                                                $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL    
                                                $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath    
                                                $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName    
                                                $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate    
     
                                                Switch ($FSLogixSettings.LocationType)    
                                                {    
                                                        "SMBLocation"       
                                                        {    
                                                                $FSLogixLocationType = "SMB Location"    
                                                                $FSLogixLocationOfProfileDisks = $FSLogixSettings.VHDLocations    
                                                                Break    
                                                        }    
                                                        "CloudCache"        
                                                        {    
                                                                $FSLogixLocationType = "Cloud Cache"    
                                                                $FSLogixLocationOfProfileDisks = $FSLogixSettings.CCDLocations    
                                                                Break    
                                                        }    
                                                        Default                     
                                                        {    
                                                                $FSLogixLocationType = "Unable to determine FSLogix Location type: $($FSLogixSettings.LocationType)"    
                                                                $FSLogixLocationOfProfileDisks = @()    
                                                                Break    
                                                        }    
                                                }    
                                                    
                                                Switch ($FSLogixSettings.ProfileDiskFormat)    
                                                {    
                                                        "VHD"   {$FSLogixProfileDiskFormat = "VHD"; Break}    
                                                        "VHDX"  {$FSLogixProfileDiskFormat = "VHDX"; Break}    
                                                        Default {$FSLogixProfileDiskFormat = "Unable to determine FSLogix Profile disk format: $($FSLogixSettings.ProfileDiskFormat)"; Break}    
                                                }    
                                                    
                                                Switch ($FSLogixSettings.AllocationType)    
                                                {    
                                                        "Dynamic"       {$FSLogixAllocationType = "Dynamic"; Break}    
                                                        "Full"          {$FSLogixAllocationType = "Full"; Break}    
                                                        Default         {$FSLogixAllocationType = "Unable to determine FSLogix Allocation type: $($FSLogixSettings.AllocationType)"; Break}    
                                                }    
                                                    
                                                $FSLogixDefaultSize = $FSLogixSettings.DefaultSize.ToString()    
                                                            
                                                #FSLogix Additional settings    
                                                #Users and Groups tab    
                                                If($FSLogixSettings.UserInclusionList.Count -eq 0)    
                                                {    
                                                        $FSLogixSettingsUserInclusionList = @("Everyone")    
                                                }    
                                                Else    
                                                {    
                                                        $FSLogixSettingsUserInclusionList = $FSLogixSettings.UserInclusionList    
                                                }    
                                                $FSLogixSettingsUserExclusionList       = $FSLogixSettings.UserExclusionList    
                                                            
                                                #Folders tab    
                                                $FSLogixSettingsCustomizeProfileFolders = $FSLogixSettings.CustomizeProfileFolders    
                                                $FSLogixSettingsExcludeCommonFolders    = $FSLogixSettings | Select-Object -ExpandProperty ExcludeCommonFolders    
                                                $ExcludedCommonFolders                  = @()    
                                                $FSLogixSettingsFolderInclusionList     = $FSLogixSettings.FolderInclusionList    
                                                $FSLogixSettingsFolderExclusionList     = $FSLogixSettings.FolderExclusionList    
     
                                                If($FSLogixSettingsCustomizeProfileFolders)    
                                                {    
                                                        #####################################################################################    
                                                        #MANY thanks to Guy Leech for helping me figure out how to process and use this Enum#    
                                                        #####################################################################################    
     
                                                        #this is cumulative    
                                                        #Contacts, Desktop, Documents, Links, MusicPodcasts, PicturesVideos, FoldersLowIntegProcesses    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Contacts)    
                                                        {    
                                                                $ExcludedCommonFolders += "Contacts"    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Desktop)    
                                                        {    
                                                                $ExcludedCommonFolders += "Desktop"    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Documents)    
                                                        {    
                                                                $ExcludedCommonFolders += "Documents"    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Links)    
                                                        {    
                                                                $ExcludedCommonFolders += "Links"    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::MusicPodcasts)    
                                                        {    
                                                                $ExcludedCommonFolders += 'Music & Podcasts'    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::PicturesVideos)    
                                                        {    
                                                                $ExcludedCommonFolders += 'Pictures & Videos'    
                                                        }    
                                                        If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::FoldersLowIntegProcesses)    
                                                        {    
                                                                $ExcludedCommonFolders += "Folders used by Low Integrity processes"    
                                                        }    
                                                }    
                                                            
                                                #Advanced tab    
                                                $FSLogixAS = $FSLogixSettings.AdvancedSettings    
                                                    
                                                Switch($FSLogixAS.AccessNetworkAsComputerObject)    
                                                {    
                                                        "Enable"        {$FSLogixAS_AccessNetworkAsComputerObject = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_AccessNetworkAsComputerObject = "Disable"; Break}    
                                                        Default         {$FSLogixAS_AccessNetworkAsComputerObject = "Unknown: $($FSLogixAS.AccessNetworkAsComputerObject)"; Break}    
                                                }    
                                                    
                                                $FSLogixAS_AttachVHDSDDL = $FSLogixAS.AttachVHDSDDL    
                                                    
                                                Switch($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)    
                                                {    
                                                        "Enable"        {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"; Break}    
                                                        Default         {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Unknown: $($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)"; Break}    
                                                }    
     
                                                $FSLogixAS_DiffDiskParentFolderPath = $FSLogixAS.DiffDiskParentFolderPath      
     
                                                Switch($FSLogixAS.FlipFlopProfileDirectoryName)    
                                                {    
                                                        "Enable"        {$FSLogixAS_FlipFlopProfileDirectoryName = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_FlipFlopProfileDirectoryName = "Disable"; Break}    
                                                        Default         {$FSLogixAS_FlipFlopProfileDirectoryName = "Unknown: $($FSLogixAS.FlipFlopProfileDirectoryName)"; Break}    
                                                }    
                                                    
                                                Switch($FSLogixAS.KeepLocalDir)    
                                                {    
                                                        "Enable"        {$FSLogixAS_KeepLocalDir = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_KeepLocalDir = "Disable"; Break}    
                                                        Default         {$FSLogixAS_KeepLocalDir = "Unknown: $($FSLogixAS.KeepLocalDir)"; Break}    
                                                }    
     
                                                $FSLogixAS_LockedRetryCount    = $FSLogixAS.LockedRetryCount                           
                                                $FSLogixAS_LockedRetryInterval = $FSLogixAS.LockedRetryInterval         
                                                    
                                                Switch($FSLogixAS.NoProfileContainingFolder)    
                                                {    
                                                        "Enable"        {$FSLogixAS_NoProfileContainingFolder = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_NoProfileContainingFolder = "Disable"; Break}    
                                                        Default         {$FSLogixAS_NoProfileContainingFolder = "Unknown: $($FSLogixAS.NoProfileContainingFolder)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.OutlookCachedMode)    
                                                {    
                                                        "Enable"        {$FSLogixAS_OutlookCachedMode = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_OutlookCachedMode = "Disable"; Break}    
                                                        Default         {$FSLogixAS_OutlookCachedMode = "Unknown: $($FSLogixAS.OutlookCachedMode)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.PreventLoginWithFailure)    
                                                {    
                                                        "Enable"        {$FSLogixAS_PreventLoginWithFailure = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_PreventLoginWithFailure = "Disable"; Break}    
                                                        Default         {$FSLogixAS_PreventLoginWithFailure = "Unknown: $($FSLogixAS.PreventLoginWithFailure)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.PreventLoginWithTempProfile)    
                                                {    
                                                        "Enable"        {$FSLogixAS_PreventLoginWithTempProfile = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_PreventLoginWithTempProfile = "Disable"; Break}    
                                                        Default         {$FSLogixAS_PreventLoginWithTempProfile = "Unknown: $($FSLogixAS.PreventLoginWithTempProfile)"; Break}                                           If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                }    
     
                                                $FSLogixAS_ProfileDirSDDL = $FSLogixAS.ProfileDirSDDL    
     
                                                Switch($FSLogixAS.ProfileType)    
                                                {    
                                                        "NormalProfile" {$FSLogixAS_ProfileType = "Normal profile"; Break}    
                                                        "OnlyRWProfile" {$FSLogixAS_ProfileType = "Only RW profile"; Break}    
                                                        "OnlyROProfile" {$FSLogixAS_ProfileType = "Only RO profile"; Break}    
                                                        "RWROProfile"   {$FSLogixAS_ProfileType = "RW/RO profile"; Break}    
                                                        Default                 {$FSLogixAS_ProfileType = "Unknown: $($FSLogixAS.ProfileType)"; Break}    
                                                }    
     
                                                $FSLogixAS_ReAttachIntervalSeconds = $FSLogixAS.ReAttachIntervalSeconds                    
                                                $FSLogixAS_ReAttachRetryCount      = $FSLogixAS.ReAttachRetryCount                         
     
                                                Switch($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)    
                                                {    
                                                        "Enable"        {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Disable"; Break}    
                                                        Default         {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Unknown: $($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.RoamSearch)    
                                                {    
                                                        "Enable"        {$FSLogixAS_RoamSearch = "Enable"; Break}    
                                                        "Disable"       {$FSLogixAS_RoamSearch = "Disable"; Break}    
                                                        Default         {$FSLogixAS_RoamSearch = "Unknown: $($FSLogixAS.RoamSearch)"; Break}    
                                                }    
     
                                                Switch($FSLogixAS.SetTempToLocalPath)    
                                                {    
                                                        "TakeNoAction"                                  {$FSLogixAS_SetTempToLocalPath = "Take no action"; Break}    
                                                        "RedirectTempAndTmp"                    {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP and TMP"; Break}    
                                                        "RedirectINetCache"                             {$FSLogixAS_SetTempToLocalPath = "Redirect INetCache"; Break}    
                                                        "RedirectTempTmpAndINetCache"   {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP, TMP, and INetCache"; Break}    
                                                        Default                                                 {$FSLogixAS_SetTempToLocalPath = "Unknown: $($FSLogixAS.SetTempToLocalPath)"; Break}    
                                                }    
     
                                                $FSLogixAS_SIDDirNameMatch   = $FSLogixAS.SIDDirNameMatch                            
                                                $FSLogixAS_SIDDirNamePattern = $FSLogixAS.SIDDirNamePattern                          
                                                $FSLogixAS_SIDDirSDDL        = $FSLogixAS.SIDDirSDDL    
                                                $FSLogixAS_VHDNameMatch      = $FSLogixAS.VHDNameMatch                               
                                                $FSLogixAS_VHDNamePattern    = $FSLogixAS.VHDNamePattern                             
     
                                                Switch($FSLogixAS.VHDXSectorSize)    
                                                {    
                                                        0               {$FSLogixAS_VHDXSectorSize = "System default"; Break}    
                                                        512             {$FSLogixAS_VHDXSectorSize = "512"; Break}    
                                                        4096    {$FSLogixAS_VHDXSectorSize = "4096"; Break}    
                                                        Default {$FSLogixAS_VHDXSectorSize = "Unknown: $($FSLogixAS.VHDXSectorSize)"; Break}    
                                                }    
     
                                                $FSLogixAS_VolumeWaitTimeMS = $FSLogixAS.VolumeWaitTimeMS                                                                   
                                        }    
                                        Else    
 
                                                #unable to retrieve default, use built-in default values <>  
                                                $TemplateTechnology                             = "Do not manage by RAS"    
                                                $FSLogixDeploymentSettingsDeploymentMethod      = "None"    
                                                $FSLogixDeploymentSettingsInstallOnlineURL      = "None"    
                                                $FSLogixDeploymentSettingsNetworkDrivePath      = "None"    
                                                $FSLogixDeploymentSettingsInstallerFileName     = "None"    
                                                $FSLogixDeploymentSettingsReplicate             = $False    
                                                $FSLogixLocationType                            = "None"    
                                                $FSLogixLocationOfProfileDisks                  = @()    
                                                $FSLogixProfileDiskFormat                       = "None"    
                                                $FSLogixAllocationType                          = "None"    
                                                $FSLogixDefaultSize                             = "0"    
                                                $FSLogixSettingsUserInclusionList               = @("Everyone")    
                                                $FSLogixSettingsUserExclusionList               = @()    
                                                $FSLogixSettingsCustomizeProfileFolders         = $False    
                                                $FSLogixSettingsExcludeCommonFolders            = "None"    
                                                $ExcludedCommonFolders                          = @()    
                                                $FSLogixSettingsFolderInclusionList             = @()    
                                                $FSLogixSettingsFolderExclusionList             = @()    
                                                $FSLogixAS_AccessNetworkAsComputerObject        = "Disable"    
                                                $FSLogixAS_AttachVHDSDDL                        = "None"    
                                                $FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"    
                                                $FSLogixAS_DiffDiskParentFolderPath             = "%TEMP"    
                                                $FSLogixAS_FlipFlopProfileDirectoryName         = "Disable"    
                                                $FSLogixAS_KeepLocalDir                         = "Disable"    
                                                $FSLogixAS_LockedRetryCount                     = 12    
                                                $FSLogixAS_LockedRetryInterval                  = 5    
                                                $FSLogixAS_NoProfileContainingFolder            = "Disable"    
                                                $FSLogixAS_OutlookCachedMode                    = "Disable"    
                                                $FSLogixAS_PreventLoginWithFailure              = "Disable"    
                                                $FSLogixAS_PreventLoginWithTempProfile          = "Disable"    
                                                $FSLogixAS_ProfileDirSDDL                       = "None"    
                                                $FSLogixAS_ProfileType                          = "Normal profile"    
                                                $FSLogixAS_ReAttachIntervalSeconds              = 10    
                                                $FSLogixAS_ReAttachRetryCount                   = 60    
                                                $FSLogixAS_RemoveOrphanedOSTFilesOnLogoff       = "Enable"    
                                                $FSLogixAS_RoamSearch                           = "Disable"    
                                                $FSLogixAS_SetTempToLocalPath                   = "Redirect TEMP, TMP, and INetCache"    
                                                $FSLogixAS_SIDDirNameMatch                      = "%sid%_%username%"    
                                                $FSLogixAS_SIDDirNamePattern                    = "%sid%_%username%"    
                                                $FSLogixAS_SIDDirSDDL                           = "None"    
                                                $FSLogixAS_VHDNameMatch                         = "Profile*"    
                                                $FSLogixAS_VHDNamePattern                       = "Profile_%username%"    
                                                $FSLogixAS_VHDXSectorSize                       = "System default"    
                                                $FSLogixAS_VolumeWaitTimeMS                     = 20000    
                                        }    
                                }    
                                Else    
                                {    
                                        #we don't inherit    
                                        #get the settings for the template    
     
                                        Switch ($VDITemplate.Technology)    
                                        {    
                                                "DoNotManage"                           {$TemplateTechnology = "Do not manage by RAS"; Break}    
                                                "FSLogixProfileContainer"       {$TemplateTechnology = "FSLogix"; Break}    
                                                Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($TemplateDefaults.Technology)"; Break}    
                                        }    
                                                            
                                        $FSLogixSettings           = $VDITemplate.FSLogix.ProfileContainer    
                                        $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}    
                                            
                                        Switch($FSLogixDeploymentSettings.InstallType)    
                                        {    
                                                "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}    
                                                "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}    
                                                "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}    
                                                "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}                                                   $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null
                                                Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}    
 
                                         +-  
                                        $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL    
                                        $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath    
                                        $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName    
                                        $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate    
                                            
                                        Switch ($FSLogixSettings.LocationType)    
                                        {    
                                                "SMBLocation"       
                                                {    
                                                        $FSLogixLocationType = "SMB Location"    
                                                        $FSLogixLocationOfProfileDisks = $FSLogixSettings.VHDLocations    
                                                        Break    
                                                }    
                                                "CloudCache"        
                                                {    
                                                        $FSLogixLocationType = "Cloud Cache"    
                                                        $FSLogixLocationOfProfileDisks = $FSLogixSettings.CCDLocations    
                                                        Break    
                                                }    
                                                Default                     
                                                {    
                                                        $FSLogixLocationType = "Unable to determine FSLogix Location type: $($FSLogixSettings.LocationType)"    
                                                        $FSLogixLocationOfProfileDisks = @()    
                                                        Break    
                                                }    
                                        }    
                                            
                                        Switch ($FSLogixSettings.ProfileDiskFormat)    
                                        {    
                                                "VHD"   {$FSLogixProfileDiskFormat = "VHD"; Break}    
                                                "VHDX"  {$FSLogixProfileDiskFormat = "VHDX"; Break}    
                                                Default {$FSLogixProfileDiskFormat = "Unable to determine FSLogix Profile disk format: $($FSLogixSettings.ProfileDiskFormat)"; Break}    
                                        }    
                                            
                                        Switch ($FSLogixSettings.AllocationType)    
                                        {    
                                                "Dynamic"       {$FSLogixAllocationType = "Dynamic"; Break}    
                                                "Full"          {$FSLogixAllocationType = "Full"; Break}    
                                                Default         {$FSLogixAllocationType = "Unable to determine FSLogix Allocation type: $($FSLogixSettings.AllocationType)"; Break}    
                                        }    
                                            
                                        $FSLogixDefaultSize = $FSLogixSettings.DefaultSize.ToString()    
                                                            
                                        #FSLogix Additional settings    
                                        #Users and Groups tab    
                                        If($FSLogixSettings.UserInclusionList.Count -eq 0)    
                                        {    
                                                $FSLogixSettingsUserInclusionList = @("Everyone")    
                                        }    
 
                                                $FSLogixSettingsUserInclusionList = $FSLogixSettings.UserInclusionList <>  
                                        }    
                                        $FSLogixSettingsUserExclusionList       = $FSLogixSettings.UserExclusionList    
                                                            
                                        #Folders tab    
                                        $FSLogixSettingsCustomizeProfileFolders = $FSLogixSettings.CustomizeProfileFolders    
                                        $FSLogixSettingsExcludeCommonFolders    = $FSLogixSettings | Select-Object -ExpandProperty ExcludeCommonFolders    
                                        $ExcludedCommonFolders                  = @()    
                                        $FSLogixSettingsFolderInclusionList     = $FSLogixSettings.FolderInclusionList    
                                        $FSLogixSettingsFolderExclusionList     = $FSLogixSettings.FolderExclusionList    
     
                                        If($FSLogixSettingsCustomizeProfileFolders)    
                                        {    
                                                #####################################################################################    
                                                #MANY thanks to Guy Leech for helping me figure out how to process and use this Enum#    
                                                #####################################################################################    
     
                                                #this is cumulative    
                                                #Contacts, Desktop, Documents, Links, MusicPodcasts, PicturesVideos, FoldersLowIntegProcesses    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Contacts)    
                                                {    
                                                        $ExcludedCommonFolders += "Contacts"    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Desktop)    
                                                {    
                                                        $ExcludedCommonFolders += "Desktop"    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Documents)    
                                                {    
                                                        $ExcludedCommonFolders += "Documents"    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Links)    
                                                {    
                                                        $ExcludedCommonFolders += "Links"    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::MusicPodcasts)    
                                                {    
                                                        $ExcludedCommonFolders += 'Music & Podcasts'    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::PicturesVideos)    
                                                {    
                                                        $ExcludedCommonFolders += 'Pictures & Videos'    
                                                }    
                                                If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::FoldersLowIntegProcesses)    
                                                {    
                                                        $ExcludedCommonFolders += "Folders used by Low Integrity processes"    
                                                }    
                                        }    
                                            
                                        #Advanced tab    
                                        $FSLogixAS = $FSLogixSettings.AdvancedSettings    
                                            
                                        Switch($FSLogixAS.AccessNetworkAsComputerObject)    
                                        {    
                                                "Enable"        {$FSLogixAS_AccessNetworkAsComputerObject = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_AccessNetworkAsComputerObject = "Disable"; Break}    
                                                Default         {$FSLogixAS_AccessNetworkAsComputerObject = "Unknown: $($FSLogixAS.AccessNetworkAsComputerObject)"; Break}    
                                        }    
                                            
                                        $FSLogixAS_AttachVHDSDDL = $FSLogixAS.AttachVHDSDDL    
                                            
                                        Switch($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)    
                                        {    
                                                "Enable"        {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"; Break}    
                                                Default         {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Unknown: $($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)"; Break}    
                                        }    
     
                                        $FSLogixAS_DiffDiskParentFolderPath = $FSLogixAS.DiffDiskParentFolderPath      
     
                                        Switch($FSLogixAS.FlipFlopProfileDirectoryName)    
                                        {    
                                                "Enable"        {$FSLogixAS_FlipFlopProfileDirectoryName = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_FlipFlopProfileDirectoryName = "Disable"; Break}    
                                                Default         {$FSLogixAS_FlipFlopProfileDirectoryName = "Unknown: $($FSLogixAS.FlipFlopProfileDirectoryName)"; Break}    
                                        }    
                                            
                                        Switch($FSLogixAS.KeepLocalDir)    
                                        {    
                                                "Enable"        {$FSLogixAS_KeepLocalDir = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_KeepLocalDir = "Disable"; Break}    
                                                Default         {$FSLogixAS_KeepLocalDir = "Unknown: $($FSLogixAS.KeepLocalDir)"; Break}    
                                        }    
     
                                        $FSLogixAS_LockedRetryCount    = $FSLogixAS.LockedRetryCount                           
                                        $FSLogixAS_LockedRetryInterval = $FSLogixAS.LockedRetryInterval         
                                            
                                        Switch($FSLogixAS.NoProfileContainingFolder)    
                                        {    
                                                "Enable"        {$FSLogixAS_NoProfileContainingFolder = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_NoProfileContainingFolder = "Disable"; Break}    
                                                Default         {$FSLogixAS_NoProfileContainingFolder = "Unknown: $($FSLogixAS.NoProfileContainingFolder)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.OutlookCachedMode)    
                                        {    
                                                "Enable"        {$FSLogixAS_OutlookCachedMode = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_OutlookCachedMode = "Disable"; Break}    
                                                Default         {$FSLogixAS_OutlookCachedMode = "Unknown: $($FSLogixAS.OutlookCachedMode)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.PreventLoginWithFailure)    
                                        {    
                                                "Enable"        {$FSLogixAS_PreventLoginWithFailure = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_PreventLoginWithFailure = "Disable"; Break}    
                                                Default         {$FSLogixAS_PreventLoginWithFailure = "Unknown: $($FSLogixAS.PreventLoginWithFailure)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.PreventLoginWithTempProfile)    
                                        {    
                                                "Enable"        {$FSLogixAS_PreventLoginWithTempProfile = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_PreventLoginWithTempProfile = "Disable"; Break}    
                                                Default         {$FSLogixAS_PreventLoginWithTempProfile = "Unknown: $($FSLogixAS.PreventLoginWithTempProfile)"; Break}    
                                        }    
     
                                        $FSLogixAS_ProfileDirSDDL = $FSLogixAS.ProfileDirSDDL    
     
                                        Switch($FSLogixAS.ProfileType)    
                                        {    
                                                "NormalProfile" {$FSLogixAS_ProfileType = "Normal profile"; Break}    
                                                "OnlyRWProfile" {$FSLogixAS_ProfileType = "Only RW profile"; Break}    
                                                "OnlyROProfile" {$FSLogixAS_ProfileType = "Only RO profile"; Break}    
                                                "RWROProfile"   {$FSLogixAS_ProfileType = "RW/RO profile"; Break}    
                                                Default         {$FSLogixAS_ProfileType = "Unknown: $($FSLogixAS.ProfileType)"; Break}    
                                        }    
     
                                        $FSLogixAS_ReAttachIntervalSeconds = $FSLogixAS.ReAttachIntervalSeconds                    
                                        $FSLogixAS_ReAttachRetryCount      = $FSLogixAS.ReAttachRetryCount                         
     
                                        Switch($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)    
                                        {    
                                                "Enable"        {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Disable"; Break}    
                                                Default         {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Unknown: $($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.RoamSearch)    
                                        {    
                                                "Enable"        {$FSLogixAS_RoamSearch = "Enable"; Break}    
                                                "Disable"       {$FSLogixAS_RoamSearch = "Disable"; Break}    
                                                Default         {$FSLogixAS_RoamSearch = "Unknown: $($FSLogixAS.RoamSearch)"; Break}    
                                        }    
     
                                        Switch($FSLogixAS.SetTempToLocalPath)    
                                        {    
                                                "TakeNoAction"                                  {$FSLogixAS_SetTempToLocalPath = "Take no action"; Break}    
                                                "RedirectTempAndTmp"                    {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP and TMP"; Break}    
                                                "RedirectINetCache"                             {$FSLogixAS_SetTempToLocalPath = "Redirect INetCache"; Break}    
                                                "RedirectTempTmpAndINetCache"   {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP, TMP, and INetCache"; Break}    
                                                Default                                                 {$FSLogixAS_SetTempToLocalPath = "Unknown: $($FSLogixAS.SetTempToLocalPath)"; Break}    
                                        }    
     
                                        $FSLogixAS_SIDDirNameMatch   = $FSLogixAS.SIDDirNameMatch                            
                                        $FSLogixAS_SIDDirNamePattern = $FSLogixAS.SIDDirNamePattern                          
                                        $FSLogixAS_SIDDirSDDL        = $FSLogixAS.SIDDirSDDL    
                                        $FSLogixAS_VHDNameMatch      = $FSLogixAS.VHDNameMatch                               
                                        $FSLogixAS_VHDNamePattern    = $FSLogixAS.VHDNamePattern                             
     
                                        Switch($FSLogixAS.VHDXSectorSize)    
                                        {    
                                                0               {$FSLogixAS_VHDXSectorSize = "System default"; Break}    
                                                512             {$FSLogixAS_VHDXSectorSize = "512"; Break}    
                                                4096    {$FSLogixAS_VHDXSectorSize = "4096"; Break}    
                                                Default {$FSLogixAS_VHDXSectorSize = "Unknown: $($FSLogixAS.VHDXSectorSize)"; Break}    
                                        }    
     
                                        $FSLogixAS_VolumeWaitTimeMS = $FSLogixAS.VolumeWaitTimeMS                                                                   
                                }    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefUserProfileSettings.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Technology"; Value = $TemplateTechnology; }) > $Null    
     
                                        If($TemplateTechnology -eq "Do not manage by RAS")    
                                        {    
                                                #do nothing    
                                        }    
                                        ElseIf($TemplateTechnology -eq "FSLogix")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null    
                                                If($FSLogixDeploymentSettings.InstallType -eq "Online")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null    
                                                }    
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null    
                                                }    
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null    
                                                }    
                                                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null
                                                $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Location type"; Value = $FSLogixLocationType; }) > $Null    
 
                                                ForEach($item in $FSLogixLocationOfProfileDisks) <>                                                 ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
 
                                                         +-  
 
                                                                $ScriptInformation.Add(@{Data = "     Location of profile disks"; Value = $item; }) > $Null <>                                                                 $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = "     Profile disk format"; Value = $FSLogixProfileDiskFormat; }) > $Null +-  
                                                $ScriptInformation.Add(@{Data = "     Allocation type"; Value = $FSLogixAllocationType; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Default size"; Value = "$FSLogixDefaultSize GB"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "Additional settings"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "     Users and Groups"; Value = ""; }) > $Null    
                                                    
                                                If($FSLogixSettingsUserInclusionList.Count -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          User Inclusion List"; Value = "None"; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $cnt = -1    
                                                        ForEach($item in $FSLogixSettingsUserInclusionList)    
                                                        {    
                                                                $cnt++    
                                                                    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "          User Inclusion List"; Value = "User: $($item.Account)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "User: $($item.Account)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                }    
                                                        }    
                                                }    
 
                                                If($FSLogixSettingsUserExclusionList.Count -eq 0) <>  
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = ""; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $cnt = -1                                                   $cnt = -1
                                                        ForEach($item in $FSLogixSettingsUserExclusionList)    
                                                        {    
                                                                $cnt++    
                                                                    
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        #$ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = "User: $($item.Account)  Type: $($item.Type)"; }) > $Null                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                                        $ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = "User: $($item.Account)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "User: $($item.Account)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null    
                                                                }    
                                                        }    
                                                }    
                                                $ScriptInformation.Add(@{Data = "     Folders"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Customize profile folders"; Value = $FSLogixSettingsCustomizeProfileFolders.ToString(); }) > $Null    
                                                If($FSLogixSettingsCustomizeProfileFolders)    
 
                                                        If($ExcludedCommonFolders.Count -gt 0) <>  
                                                        {    
                                                                $cnt = -1    
                                                                ForEach($item in $ExcludedCommonFolders)    
                                                                {    
                                                                        $cnt++                                                           $cnt++
                                                                            
                                                                        If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                        {                                                           {
                                                                                $ScriptInformation.Add(@{Data = "               Exclude Common Folders"; Value = $item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null
                                                                        }                                                           }
                                                                        Else                                                           Else
                                                                        {                                                           {
                                                                                $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                        }    
                                                                }    
 
                                                        Else +-  
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "               Exclude Common Folders"; Value = "None"; }) > $Null    
                                                        }    
 
  <>  
                                                If($FSLogixSettingsFolderInclusionList.Count -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          Folder Inclusion List"; Value = "None"; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          Folder Inclusion List"; Value = ""; }) > $Null    
                                                        $cnt = -1    
                                                        ForEach($item in $FSLogixSettingsFolderInclusionList)    
                                                        {    
                                                                $cnt++    
                                                                                                                  
                                                                If($cnt -eq 0)    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = "               Folder"; Value = "$item"; }) > $Null    
                                                                }    
                                                                Else    
                                                                {    
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "$item"; }) > $Null    
                                                                }    
                                                        }    
                                                }    
     
                                                If($FSLogixSettingsFolderExclusionList.Count -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          Folder Exclusion List"; Value = "None"; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "          Folder Exclusion List"; Value = ""; }) > $Null    
                                                        $cnt = -1                                                   $cnt = -1
                                                        ForEach($item in $FSLogixSettingsFolderExclusionList)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                        {                                                   {
                                                                $cnt++                                                           $cnt++
                                                                    
                                                                Switch($item.ExcludeFolderCopy)    
                                                                {    
                                                                        "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}    
                                                                        "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}    
                                                                        "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}    
                                                                        "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}    
                                                                        Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}    
                                                                }    
                                                                    
                                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                {                                                           {
                                                                        $ScriptInformation.Add(@{Data = "               Folder"; Value = "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        $ScriptInformation.Add(@{Data = ""; Value = "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                }    
 
                                                 +-  
                                                $ScriptInformation.Add(@{Data = "     Advanced"; Value = ""; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          FSLogix Setting:"; Value = "Value:"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Access network as computer object"; Value = "$($FSLogixAS_AccessNetworkAsComputerObject)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Custom SDDL for profile directory"; Value = "$($FSLogixAS_ProfileDirSDDL)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Delay between locked VHD(X) retries"; Value = "$($FSLogixAS_LockedRetryInterval)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Delete local profile when loading from VHD"; Value = "$($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Diff disk parent folder path"; Value = "$($FSLogixAS_DiffDiskParentFolderPath)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Do not create a folder for new profiles"; Value = "$($FSLogixAS_NoProfileContainingFolder)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Enable Cached mode for Outlook"; Value = "$($FSLogixAS_OutlookCachedMode)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Keep local profiles"; Value = "$($FSLogixAS_KeepLocalDir)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Naming pattern for new VHD(X) files"; Value = "$($FSLogixAS_VHDNamePattern)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Number of locked VHD(X) retries"; Value = "$($FSLogixAS_LockedRetryCount)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Prevent logons with failures"; Value = "$($FSLogixAS_PreventLoginWithFailure)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Prevent logons with temp profiles"; Value = "$($FSLogixAS_PreventLoginWithTempProfile)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Profile folder naming pattern"; Value = "$($FSLogixAS_SIDDirNameMatch)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Profile type"; Value = "$($FSLogixAS_ProfileType)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Profile VHD(X) file matching pattern"; Value = "$($FSLogixAS_VHDNameMatch)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Re-attach interval"; Value = "$($FSLogixAS_ReAttachIntervalSeconds)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Re-attach retry limit"; Value = "$($FSLogixAS_ReAttachRetryCount)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Remove duplicate OST files on logoff"; Value = "$($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          SDDL used when attaching the VHD"; Value = "$($FSLogixAS_AttachVHDSDDL)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Search roaming feature mode"; Value = "$($FSLogixAS_RoamSearch)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Swap SID and username in profile directory names"; Value = "$($FSLogixAS_FlipFlopProfileDirectoryName)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Temporary folders redirection mode"; Value = "$($FSLogixAS_SetTempToLocalPath)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Use SDDL on creation of SID containing folder"; Value = "$($FSLogixAS_SIDDirSDDL)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          User-to-Profile matching pattern"; Value = "$($FSLogixAS_SIDDirNamePattern)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          VHDX sector size"; Value = "$($FSLogixAS_VHDXSectorSize)"; }) > $Null    
                                                $ScriptInformation.Add(@{Data = "          Volume wait time"; Value = "$($FSLogixAS_VolumeWaitTimeMS)"; }) > $Null    
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite +-  
 
                                If($Text) <>  
                                    WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
 
                                        Line 3 "Inherit default settings`t`t`t`t: " $VDITemplate.InheritDefUserProfileSettings.ToString() <>                                         $ScriptInformation = New-Object System.Collections.ArrayList
                                        Line 3 "Technology`t`t`t`t`t`t: " $TemplateTechnology                                           $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null
 
                                        If($TemplateTechnology -eq "Do not manage by RAS") <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)
 
                                                #do nothing <>                                                         If($Null -eq $item.DisplayName)
                                                            {
                                                                    $DisplayName = ""
                                        }                                                           }
                                        ElseIf($TemplateTechnology -eq "FSLogix")                                                           Else
                                        {                                                           {
                                                Line 3 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod                                                                   $DisplayName = $item.DisplayName
                                                If($FSLogixDeploymentSettings.InstallType -eq "Online")                                                           }
                                                            If($Null -eq $item.ComponentName)
                                                {                                                           {
                                                        Line 3 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL                                                                   $ComponentName = ""
                                                }                                                           }
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")                                                           Else
                                                {                                                           {
                                                        Line 10 ": " $FSLogixDeploymentSettingsNetworkDrivePath                                                                   $ComponentName = $item.ComponentName
                                                            }
                                                    $OptimizationTable += @{
                                                            DisplayName = $DisplayName
                                                            ComponentName = $ComponentName
 
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall") <>                                         }
     
                                            If($OptimizationTable.Count -gt 0)
                                                {                                           {
                                                        Line 10 ": " $FSLogixDeploymentSettingsInstallerFileName                                                   $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns DisplayName, ComponentName `
                                                    -Headers "Display name", "Component" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 200;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                                }                                           }
                                                Line 3 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()    
                                                Line 3 "Settings"    
                                                Line 4 "Location type`t`t`t`t`t: " $FSLogixLocationType    
                                                                                   }
                                                $cnt = -1    
                                                ForEach($item in $FSLogixLocationOfProfileDisks)                                   WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                                {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null
                                                        $cnt++    
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                                                                          
                                                        If($cnt -eq 0)                                           ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)
                                            {
                                                            If($Null -eq $item.DisplayName)
 
                                                                Line 4 "Location of profile disks`t`t`t: " $item <>                                                                 $DisplayName = ""
 
                                                                Line 10 "  " $item <>                                                                 $DisplayName = $item.DisplayName
 
                                                } <>                                                         If($Null -eq $item.ServiceName)
                                                Line 4 "Profile disk format`t`t`t`t: " $FSLogixProfileDiskFormat    
                                                Line 4 "Allocation type`t`t`t`t`t: " $FSLogixAllocationType    
                                                Line 4 "Default size`t`t`t`t`t: " "$FSLogixDefaultSize GB"    
                                                Line 3 "Additional settings"    
                                                Line 4 "Users and Groups"    
                                                    
                                                If($FSLogixSettingsUserInclusionList.Count -eq 0)    
                                                {                                                           {
                                                        Line 5 "User Inclusion List`t`t`t: " "None"                                                                   $Service = ""
                                                }                                                           }
                                                Else                                                           Else
                                                {                                                           {
                                                        $cnt = -1                                                                   $Service = $item.ServiceName
                                                        ForEach($item in $FSLogixSettingsUserInclusionList)    
                                                        {                                                           }
                                                                $cnt++                                                           If($Null -eq $item.Aliases)
                                                                    
                                                                If($cnt -eq 0)    
                                                                {                                                           {
                                                                        Line 5 "User Inclusion List`t`t`t: " "User: $($item.Account)  Type: $($item.Type)"                                                                   $Aliases = ""
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        Line 10 "  " "User: $($item.Account)  Type: $($item.Type)"                                                                   $Aliases = $item.Aliases
                                                                }                                                           }
                                                    $OptimizationTable += @{
                                                            DisplayName = $DisplayName
                                                            Service     = $Service
                                                            Aliases     = $Aliases
                                                        }                                                   }
                                                }                                           }
 
                                                If($FSLogixSettingsUserExclusionList.Count -eq 0) <>                                         If($OptimizationTable.Count -gt 0)
                                                {                                           {
                                                        Line 5 "User Exclusion List`t`t`t: " "None"                                                   $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns DisplayName, Service, Aliases `
                                                    -Headers "Display name", "Service", "Aliases" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 100;
                                                    $Table.Columns.Item(3).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                                }                                           }
                                    }
                                    
                                    WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                            {
                                                            If($Null -eq $item.Task)
                                                            {
                                                                    $Task = ""
                                                            }
                                                Else                                                           Else
                                                {                                                           {
                                                                    $Task = $item.Task
                                                        $cnt = -1                                                           }
                                                        ForEach($item in $FSLogixSettingsUserExclusionList)                                                           If($Null -eq $item.Type)
 
  <>                                                                 $Type = ""
                                                                $cnt++                                                           }
                                                            Else
                                                                                                                           {
                                                                    $Type = $item.Type.ToString()
                                                            }
                                                                If($cnt -eq 0)                                                           If($Null -eq $item.Location)
                                                                {                                                           {
                                                                        Line 5 "User Exclusion List`t`t`t: " "User: $($item.Account)  Type: $($item.Type)"                                                                   $Location = ""
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        Line 10 "  " "User: $($item.Account)  Type: $($item.Type)"                                                                   $Location = $item.Location
                                                                }                                                           }
                                                    $OptimizationTable += @{
                                                            Task     = $Task
                                                            Type     = $Type
                                                            Location = $Location
                                                        }                                                   }
                                                }                                           }
                                                Line 4 "Folders"    
                                                Line 5 "Customize profile folders`t`t: " $FSLogixSettingsCustomizeProfileFolders.ToString()                                           If($OptimizationTable.Count -gt 0)
                                                If($FSLogixSettingsCustomizeProfileFolders)    
                                                {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Task, Type, Location `
                                                    -Headers "Task", "Type", "Location" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                        If($ExcludedCommonFolders.Count -gt 0)                                                   $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 250;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                                        {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null
                                                                $cnt = -1    
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                                ForEach($item in $ExcludedCommonFolders)                                           FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Disable Hibernate"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Telemetry collection"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable System Restore"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable error reporting to send additional data"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Tiles"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable Cortana digital assistant"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Turn off Microsoft consumer experience"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Do not show Windows tips"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Remove Common program groups from the Start Menu"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()
                                                    Value   = ""
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Partial Start Menu layout"
                                                    Enabled = $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()
                                                    Value   = $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                                                {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled, Value `
                                                    -Headers "Setting", "Enabled", "Value" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
                                                                        $cnt++    
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 275;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 175;
                                                                                                                          
                                                                        If($cnt -eq 0)                                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTNetworkPerformanceEnabled -eq "True")
                                                                        {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "FileInfoCacheEntriesMax"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()
                                                    Value   = $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "DirectoryCacheEntriesMax"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()
                                                    Value   = $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax
                                            }
     
                                            $OptimizationTable += @{
                                                                                Line 6 "Exclude Common Folders`t`t: " $item                                                   Setting = "FileNotFoundCacheEntriesMax"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()
                                                    Value   = $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache
                                                                        }                                           }
                                                                        Else    
                                            $OptimizationTable += @{
                                                    Setting = "DormantFileLimit"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()
                                                    Value   = $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit
                                                                        {                                           }
                                                                                Line 10 "  " $item    
                                            $OptimizationTable += @{
                                                    Setting = "Disable TCP/IP Task Offload"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString()
                                                    Value   = ""
                                                                        }                                           }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable IPv6 Components"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()
                                                    Value   = ""
                                                                }                                           }
     
                                            $OptimizationTable += @{
                                                    Setting = "Disable IPv6 to IPv4"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()
                                                    Value   = ""
                                                        }                                           }
                                                        Else    
                                            $OptimizationTable += @{
                                                    Setting = "Disables isatap for IPv6"
                                                    Enabled = $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString()
                                                    Value   = ""
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                                        {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled, Value `
                                                    -Headers "Setting", "Enabled", "Value" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 150;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    $Table.Columns.Item(3).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                                Line 6 "Exclude Common Folders`t`t: None"                                                   FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                                        }                                           }
                                                }                                   }
 
  <>                                 WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled
                                    If($OPTRegistryEnabled -eq "True")
                                    {
                                                If($FSLogixSettingsFolderInclusionList.Count -eq 0)                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
     
                                            ForEach($item in $RDSTemplate.Optimization.Registry.RegistryList)
                                                {                                           {
                                                        Line 5 "Folder Inclusion List`t`t`t: " "None"                                                   $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                }                                           }
                                                Else    
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 125;
                                            $Table.Columns.Item(2).Width = 375;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    
                                    WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                                {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Animate controls and elements inside windows"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Animate windows when minimizing and maximizing"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Animations in the taskbar"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Enable Peek"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                        Line 5 "Folder Inclusion List"                                                   Setting = "Fade or slide menus into view"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString()
                                            }
                                                        $cnt = -1    
                                            $OptimizationTable += @{
                                                    Setting = "Fade or slide Tooltips into view"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Fade out menu items after clicking"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Save taskbar thumbnail previews"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show shadows under mouse pointer"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show shadows under windows"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                        ForEach($item in $FSLogixSettingsFolderInclusionList)                                                   Setting = "Show thumbnails instead of icons"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show translucent selection rectangle"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Show window contents while dragging"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Slide open combo boxes"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Smooth edges of screen fonts"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Smooth-scroll list boxes"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Use drop shadows for icon labels on the desktop"
                                                    Enabled = $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString()
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                                        {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled `
                                                    -Headers "Setting", "Enabled" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
                                                                $cnt++    
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 250;
                                                    $Table.Columns.Item(2).Width = 50;
                                                                                                                  
                                                                If($cnt -eq 0)                                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    
                                    WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                                                {                                   {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 15;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                                                        Line 6 "Folder`t`t`t`t: " $item                                           WriteWordLine 0 0 ""
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $OptimizationTable = @()
                    
                                            $OptimizationTable += @{
                                                    Setting = "Clean up redundant system files"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString()
                                                                }                                           }
                                                                Else    
                                            $OptimizationTable += @{
                                                    Setting = "Clean up the WinSxS Folder"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Clean up temporary files and logs"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Remove OneDrive"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString()
                                            }
     
                                            $OptimizationTable += @{
                                                    Setting = "Delete users' profiles"
                                                    Enabled = $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString()
                                            }
     
                                            If($OptimizationTable.Count -gt 0)
                                                                {                                           {
                                                    $Table = AddWordTable -Hashtable $OptimizationTable `
                                                    -Columns Setting, Enabled `
                                                    -Headers "Setting", "Enabled" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 175;
                                                    $Table.Columns.Item(2).Width = 50;
                                                    
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                                        Line 10 "  " $item                                                   WriteWordLine 0 0 ""
                                                                }                                           }
                                                        }                                   }
     
                                    WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled -eq "True")
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Command"; Value = $RDSTemplate.Optimization.CustomScript.Command; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Arguments"; Value = $RDSTemplate.Optimization.CustomScript.Arguments; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $RDSTemplate.Optimization.CustomScript.InitDir; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Username"; Value = $RDSTemplate.Optimization.CustomScript.User; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 100;
                                            $Table.Columns.Item(2).Width = 200;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                                }                                   }
                            }
                                                If($FSLogixSettingsFolderExclusionList.Count -eq 0)                           If($Text)
                                                {                           {
                                                        Line 5 "Folder Exclusion List`t`t`t: " "None"                                   Line 3 "Inherit default settings`t: " $RDSTemplate.InheritDefaultOptimizationSettings.ToString()
                                    Line 3 "Enable optimization`t`t: " $OPTEnableOptimization
                                    Line 3 "Optimization type`t`t: " $OPTOptimizationType
                                    Line 3 "Category"
                                    
                                    Line 4 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            Line 5 "Windows Defender ATP Optimizations"
                                            If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                            {
                                                    Line 6 "Turn off Windows Defender ATP (I use my own ATP solution)"
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                    Line 6 "Turn on Windows Defender ATP and set process and folder exclusions"
                                                    Line 6 "Disable real-time protection: " $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()
                                                    Line 0 ""
                                                        Line 5 "Folder Exclusion List"                                                   Line 6 "Exclude files and folders:"
                                                        $cnt = -1    
                                                        ForEach($item in $FSLogixSettingsFolderExclusionList)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                        {                                                   {
                                                                $cnt++                                                           Line 7 $item
                                                                    
                                                                Switch($item.ExcludeFolderCopy)    
                                                                {    
                                                                        "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}    
                                                                        "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}    
                                                                        "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}    
                                                                        "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}    
                                                                        Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}    
                                                                }                                                   }
                                                                    
                                                                If($cnt -eq 0)                                                   Line 6 "Exclude processes:"
                                                    ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                                {                                                   {
                                                                        Line 6 "Folder`t`t`t`t: " "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"                                                           Line 7 $item
                                                                }                                                   }
                                                                Else                                                  
                                                    Line 6 "Exclude extensions:"
                                                    ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                                {                                                   {
                                                                        Line 10 "  " "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"                                                           Line 7 $item
                                                                }                                                   }
                                                        }                                           }
                                            
                                            Line 0 ""
                                                }                                   }
                                                                                  
                                    Line 4 "Windows Components: " $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                    {
                                            Line 5 "Windows Components Optimizations"
                                            Line 6 "Disable (remove) components:"
                                                Line 4 "Advanced"                                           Line 0 ""
                                                Line 5 "FSLogix Setting                                      Value"                                           Line 6 "Display name                                        Component                                         "
                                                Line 5 "======================================================================================"                                           Line 6 "======================================================================================================"
                                                #      "Swap SID and username in profile directory names     Redirect TEMP, TMP, and INetCache"                                           #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890
                                                Line 6 "Access network as computer object                    $($FSLogixAS_AccessNetworkAsComputerObject)"    
                                                Line 6 "Custom SDDL for profile directory                    $($FSLogixAS_ProfileDirSDDL)"    
                                                Line 6 "Delay between locked VHD(X) retries                  $($FSLogixAS_LockedRetryInterval)"    
                                                Line 6 "Delete local profile when loading from VHD           $($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"    
                                                Line 6 "Diff disk parent folder path                         $($FSLogixAS_DiffDiskParentFolderPath)"    
                                                Line 6 "Do not create a folder for new profiles              $($FSLogixAS_NoProfileContainingFolder)"    
                                                Line 6 "Enable Cached mode for Outlook                       $($FSLogixAS_OutlookCachedMode)"    
                                                Line 6 "Keep local profiles                                  $($FSLogixAS_KeepLocalDir)"    
                                                Line 6 "Naming pattern for new VHD(X) files                  $($FSLogixAS_VHDNamePattern)"    
                                                Line 6 "Number of locked VHD(X) retries                      $($FSLogixAS_LockedRetryCount)"    
                                                Line 6 "Prevent logons with failures                         $($FSLogixAS_PreventLoginWithFailure)"    
                                                Line 6 "Prevent logons with temp profiles                    $($FSLogixAS_PreventLoginWithTempProfile)"    
                                                Line 6 "Profile folder naming pattern                        $($FSLogixAS_SIDDirNameMatch)"    
                                                Line 6 "Profile type                                         $($FSLogixAS_ProfileType)"    
                                                Line 6 "Profile VHD(X) file matching pattern                 $($FSLogixAS_VHDNameMatch)"    
                                                Line 6 "Re-attach interval                                   $($FSLogixAS_ReAttachIntervalSeconds)"    
                                                Line 6 "Re-attach retry limit                                $($FSLogixAS_ReAttachRetryCount)"    
                                                Line 6 "Remove duplicate OST files on logoff                 $($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"    
                                                Line 6 "SDDL used when attaching the VHD                     $($FSLogixAS_AttachVHDSDDL)"    
                                                Line 6 "Search roaming feature mode                          $($FSLogixAS_RoamSearch)"    
                                                Line 6 "Swap SID and username in profile directory names     $($FSLogixAS_FlipFlopProfileDirectoryName)"    
                                                Line 6 "Temporary folders redirection mode                   $($FSLogixAS_SetTempToLocalPath)"    
                                                Line 6 "Use SDDL on creation of SID containing folder        $($FSLogixAS_SIDDirSDDL)"    
                                                Line 6 "User-to-Profile matching pattern                     $($FSLogixAS_SIDDirNamePattern)"                                           #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component
                                                Line 6 "VHDX sector size                                     $($FSLogixAS_VHDXSectorSize)"                                           ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                Line 6 "Volume wait time                                     $($FSLogixAS_VolumeWaitTimeMS)"                                           {
                                                    Line 6 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)
 
  +-  
 
                                If($HTML) <>                                
                                    Line 4 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
 
                                        $rowdata = @() <>                                         Line 5 "Windows Services Optimizations"
                                        $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefUserProfileSettings.ToString(),$htmlwhite)                                           Line 6 "Disable services:"
                                        $rowdata += @(,("Technology",($Script:htmlsb),$TemplateTechnology,$htmlwhite))    
                                            Line 0 ""
                                        If($TemplateTechnology -eq "Do not manage by RAS")                                           Line 6 "Display name                                        Service                         Aliases             "
                                            Line 6 "========================================================================================================"
                                            #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890
                                            #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth
                                            ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)
 
                                                #do nothing <>                                                 Line 6 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)
 
  <>                                         Line 0 ""
                                    }
                                    
                                    Line 4 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                        ElseIf($TemplateTechnology -eq "FSLogix")                                   If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                    {
                                            Line 5 "Windows Scheduled Tasks Optimizations"
                                            Line 6 "Disable tasks:"
                                            Line 0 ""
                                            Line 6 "Task                                                Type    Location                                          "
                                            Line 6 "=============================================================================================================="
                                            #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890
                                            #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\
                                            ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
 
                                                $rowdata += @(,("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite)) <>                                                 Line 6 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)
                                                If($FSLogixDeploymentSettings.InstallType -eq "Online")                                           }
                                            Line 0 ""
                                    }
     
                                    Line 4 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                                {                                   {
                                            Line 5 "Windows Advanced Options"
                                            Line 0 ""
                                            Line 6 "Setting                                           Enabled  Value                                             "
                                            Line 6 "============================================================================================================="
                                            #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890
                                            #               Remove Common program groups from the start menu  False    SomeConfigFile.xml
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Hibernate", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Telemetry collection", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable System Restore", `
                                                        $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))                                           $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable error reporting to send additional data", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Tiles", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Disable Cortana digital assistant", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Turn off Microsoft consumer experience", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Do not show Windows tips", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Remove Common program groups from the Start Menu", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                            "Partial Start Menu layout", `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `
                                            $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)
                                            
                                            Line 0 ""
                                                }                                   }
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                                    Line 4 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTNetworkPerformanceEnabled -eq "True")
                                                {                                   {
                                            Line 5 "Network Performance Optimizations"
                                            Line 0 ""
                                            Line 6 "Setting                      Enabled  Value"
                                            Line 6 "==========================================="
                                            #               123456789012345678901234567SS1234567SS12345
                                            #               FileNotFoundCacheEntriesMax  False    32768
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "FileInfoCacheEntriesMax", `
                                            $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `
                                            $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache)
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "DirectoryCacheEntriesMax", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `
                                            $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax)
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "FileNotFoundCacheEntriesMax", `
                                            $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `
                                            $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache)
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "DormantFileLimit", `
                                                        $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))                                           $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `
                                            $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit)
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable TCP/IP Task Offload", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable IPv6 Components", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disable IPv6 to IPv4", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `
                                            "")
                                            
                                            Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                            "Disables isatap for IPv6", `
                                            $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `
                                            "")
                                            
                                            Line 0 ""
                                                }                                   }
                                                ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")    
                                    Line 4 "Registry: " $OPTRegistryEnabled
                                    If($OPTRegistryEnabled -eq "True")
                                                {                                   {
                                            Line 5 "Registry Optimizations"
                                            Line 0 ""
                                            #               123456789012345678901234567SS1234567SS12345
                                            #               FileNotFoundCacheEntriesMax  False    32768
                                            Line 6 "Registry                                  Action  Value                 Type           Data                  Path                                                        "
                                            Line 6 "========================================================================================================================================================================="
                                            #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890
                                            #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk
                                                        $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))                                           ForEach($item in $RDSTemplate.Optimization.Registry.RegistryList)
                                            {
                                                    Line 6 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `
                                                    $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType, $item.DWORDValue, "$($item.HiveType)\$($item.Path)")
                                                }                                           }
                                                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))                                           Line 0 ""
                                                $rowdata += @(,("Settings",($Script:htmlsb),"",$htmlwhite))                                   }
                                                $rowdata += @(,("     Location type",($Script:htmlsb),$FSLogixLocationType,$htmlwhite))    
                                    Line 4 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                    {
                                            Line 5 "Visual Effects Optimizations"
                                            Line 0 ""
                                                                                          
                                                $cnt = -1                                           Switch ($RDSTemplate.Optimization.VisualEffects.VisualEffectsTypes)
                                                ForEach($item in $FSLogixLocationOfProfileDisks)    
                                                {                                           {
                                                    "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}
                                                    "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs
                                                    "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}
                                                    "Custom"                                        {$VisualEffectsType = "Custom"; Break}
                                                    Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($RDSTemplate.Optimization.VisualEffects.VisualEffectsTypes)"; Break}
                                                        $cnt++                                           }
                                            Line 6 $VisualEffectsType
                                            Line 0 ""
                                            Line 6 "Setting                                             Enabled"
                                            Line 6 "==========================================================="
                                            #               12345678901234567890123456789012345678901234567890SS1234567
                                            #               Use drop shadows for icon labels on the desktop     False  
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Animate controls and elements inside windows", `
                                            $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString())
                                                                                                  
                                                        If($cnt -eq 0)                                           Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Animate windows when minimizing and maximizing", `
                                            $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Animations in the taskbar", `
                                            $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Enable Peek", `
                                            $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Fade or slide menus into view", `
                                            $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Fade or slide Tooltips into view", `
                                            $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Fade out menu items after clicking", `
                                            $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Save taskbar thumbnail previews", `
                                            $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show shadows under mouse pointer", `
                                            $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show shadows under windows", `
                                            $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show thumbnails instead of icons", `
                                            $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show translucent selection rectangle", `
                                            $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Show window contents while dragging", `
                                            $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Slide open combo boxes", `
                                            $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Smooth edges of screen fonts", `
                                            $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Smooth-scroll list boxes", `
                                            $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())
                                            
                                            Line 6 ( "{0,-50}  {1,-7}" -f `
                                            "Use drop shadows for icon labels on the desktop", `
                                            $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString())
                                            
                                            Line 0 ""
                                    }
     
                                    Line 4 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                                        {                                   {
                                                                $rowdata += @(,("     Location of profile disks",($Script:htmlsb),$item,$htmlwhite))                                           Line 5 "Disk Cleanup Optimizations"
                                            Line 0 ""
                                            
                                            Line 6 "Setting                            Enabled"
                                            Line 6 "=========================================="
                                            #               123456789012345678901234567890123SS1234567
                                            #               Clean up temporary files and logs  False  
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up redundant system files", `
                                            $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString())
                                            
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up the WinSxS Folder", `
                                            $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())
                                            
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Clean up temporary files and logs", `
                                            $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())
                                            
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Remove OneDrive", `
                                            $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString())
                                            
                                            Line 6 ( "{0,-33}  {1,-7}" -f `
                                            "Delete users' profiles", `
                                            $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString())
                                            
                                            Line 0 ""
                                                        }                                   }
                                                        Else    
                                    Line 4 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled  -eq "True")
                                                        {                                   {
                                                                $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))                                           Line 5 "Custom Script"
                                            Line 0 ""
                                            
                                            Line 6 "Command`t`t : " $RDSTemplate.Optimization.CustomScript.Command
                                            Line 6 "Arguments`t : " $RDSTemplate.Optimization.CustomScript.Arguments
                                            Line 6 "Initial directory: " $RDSTemplate.Optimization.CustomScript.InitDir
                                            Line 6 "Username`t : " $RDSTemplate.Optimization.CustomScript.User
                                            Line 0 ""
                                                        }                                   }
                                    Line 0 ""
                                                }                           }
                            If($HTML)
                            {
                                    $rowdata = @()
                                                $rowdata += @(,("     Profile disk format",($Script:htmlsb),$FSLogixProfileDiskFormat,$htmlwhite))                                   $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$RDSTemplate.InheritDefaultOptimizationSettings.ToString(),$htmlwhite)
                                                $rowdata += @(,("     Allocation type",($Script:htmlsb),$FSLogixAllocationType,$htmlwhite))                                   $rowdata += @(,("Enable optimization:",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))
                                                $rowdata += @(,("     Default size",($Script:htmlsb),"$FSLogixDefaultSize GB",$htmlwhite))    
                                                $rowdata += @(,("Additional settings",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Optimization type:",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))
     
                                    $msg = "Optimization"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                    If($OPTWindowsDefenderATPEnabled -eq "True")
                                    {
                                            $rowdata = @()
                                                $rowdata += @(,("     Users and Groups",($Script:htmlsb),"",$htmlwhite))                                           $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)
                                                    
                                                If($FSLogixSettingsUserInclusionList.Count -eq 0)                                           If($RDSTemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                {                                           {
                                                        $rowdata += @(,("          User Inclusion List",($Script:htmlsb),"None",$htmlwhite))                                                   $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                    $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))
                                                    $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $RDSTemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))
                                                    $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))
                                                    
                                                        $cnt = -1                                                   $cnt = -1
                                                        ForEach($item in $FSLogixSettingsUserInclusionList)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                        {                                                   {
                                                                $cnt++                                                           $cnt++
                                                                    
                                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                {                                                           {
                                                                        $rowdata += @(,("          User Inclusion List",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))                                                                   $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))
                                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        $rowdata += @(,("",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                }    
 
                                                If($FSLogixSettingsUserExclusionList.Count -eq 0) <>  
                                                {    
                                                        $rowdata += @(,("          User Exclusion List",($Script:htmlsb),"None",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $cnt = -1                                                   $cnt = -1
                                                        ForEach($item in $FSLogixSettingsUserExclusionList)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                        {                                                   {
                                                                $cnt++                                                           $cnt++
                                                                    
                                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                {                                                           {
                                                                        $rowdata += @(,("          User Exclusion List",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))                                                                   $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))
                                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
                                                                }                                                           }
                                                                Else                                                           Else
                                                                {                                                           {
                                                                        $rowdata += @(,("",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))    
                                                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                }    
 
                                                $rowdata += @(,("     Folders",($Script:htmlsb),"",$htmlwhite)) <>  
                                                $rowdata += @(,("          Customize profile folders",($Script:htmlsb),$FSLogixSettingsCustomizeProfileFolders.ToString(),$htmlwhite))    
                                                If($FSLogixSettingsCustomizeProfileFolders)    
                                                {                                                  
                                                        If($ExcludedCommonFolders.Count -gt 0)    
                                                        {    
                                                                $cnt = -1                                                   $cnt = -1
                                                                ForEach($item in $ExcludedCommonFolders)                                                   ForEach($item in $RDSTemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                                {                                                   {
                                                                        $cnt++                                                           $cnt++
                                                                            
                                                                        If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                                        {                                                           {
                                                                                $rowdata += @(,("               Exclude Common Folders",($Script:htmlsb),$item,$htmlwhite))                                                                   $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))
                                                                        }                                                           }
                                                                        Else                                                           Else
                                                                        {                                                           {
                                                                                $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                        }                                                           }
                                                                }                                                   }
                                                        }                                           }
                                                        Else    
     
                                            $msg = ""
                                            $columnWidths = @("300","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled
                                    If($OPTWindowsComponentsEnabled -eq "True")
                                                        {                                   {
                                                                $rowdata += @(,("               Exclude Common Folders",($Script:htmlsb),"None",$htmlwhite))                                           WriteHTMLLine 0 0 "Windows Components Optimizations"
     
                                            $rowdata = @()
     
                                            ForEach($item in $RDSTemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                        }                                           {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.ComponentName,$htmlwhite)
                                                    )
                                                }                                           }
 
                                                If($FSLogixSettingsFolderInclusionList.Count -eq 0) <>                                         $columnHeaders = @(
                                                    "Display Name",($Script:htmlsb),
                                                    "Component",($Script:htmlsb)
                                                {                                           )
                                                        $rowdata += @(,("          Folder Inclusion List",($Script:htmlsb),"None",$htmlwhite))    
                                            $msg = "Disable (remove) components:"
                                            $columnWidths = @("200","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                }                                   }
                                                Else    
                                    WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                    If($OPTWindowsServicesEnabled -eq "True")
                                                {                                   {
                                                        $rowdata += @(,(         Folder Inclusion List",($Script:htmlsb),"",$htmlwhite))                                           WriteHTMLLine 0 0 "Windows Services Optimizations"
                                                        $cnt = -1    
                                            $rowdata = @()
     
                                                        ForEach($item in $FSLogixSettingsFolderInclusionList)                                           ForEach($item in $RDSTemplate.Optimization.WindowsServices.WindowsServicesList)
                                                        {                                           {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.ServiceName,$htmlwhite,
                                                            $item.Aliases,$htmlwhite)
                                                    )
                                            }
                                                                $cnt++    
                                            $columnHeaders = @(
                                                    "Display Name",($Script:htmlsb),
                                                    "Service",($Script:htmlsb),
                                                    "Aliases",($Script:htmlsb)
                                            )
                                                                    
                                                                If($cnt -eq 0)                                           $msg = "Disable services:"
                                            $columnWidths = @("200","100","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
     
                                    WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled
                                    If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                                                {                                   {
                                                                        $rowdata += @(,("               Folder",($Script:htmlsb),"$item",$htmlwhite))                                           WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"
                                                                }    
                                            $rowdata = @()
                                                                Else    
                                            ForEach($item in $RDSTemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                                                {                                           {
                                                                        $rowdata += @(,("",($Script:htmlsb),"$item",$htmlwhite))                                                   $rowdata += @(,(
                                                            $item.Task,$htmlwhite,
                                                            $item.Type.Tostring(),$htmlwhite,
                                                            $item.Location,$htmlwhite)
                                                    )
                                                                }                                           }
     
                                            $columnHeaders = @(
                                                    "Task",($Script:htmlsb),
                                                    "Type",($Script:htmlsb),
                                                    "Location",($Script:htmlsb)
                                            )
     
                                            $msg = "Disable tasks:"
                                            $columnWidths = @("200","50","250")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                        }                                   }
     
                                    WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                    {
                                            WriteHTMLLine 0 0 "Windows Advanced Options"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Disable Hibernate",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Telemetry collection",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable System Restore",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable error reporting to send additional data",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Tiles",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable Cortana digital assistant",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Turn off Microsoft consumer experience",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Do not show Windows tips",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Remove Common program groups from the Start Menu",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Partial Start Menu layout",$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb),
                                                    "Value",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("300","50","200")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                }                                   }
 
                                                If($FSLogixSettingsFolderExclusionList.Count -eq 0) <>                                 WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                    If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                                {                                   {
                                            WriteHTMLLine 0 0 "Network Performance Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "FileInfoCacheEntriesMax",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "DirectoryCacheEntriesMax",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                        $rowdata += @(,("          Folder Exclusion List",($Script:htmlsb),"None",$htmlwhite))                                                   "FileNotFoundCacheEntriesMax",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "DormantFileLimit",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable TCP/IP Task Offload",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable IPv6 Components",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disable IPv6 to IPv4",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Disables isatap for IPv6",$htmlwhite,
                                                    $RDSTemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,
                                                    "",$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb),
                                                    "Value",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("170","50","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                }                                   }
                                                Else    
                                    WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled       
                                    If($OPTRegistryEnabled -eq "True")
                                                {                                   {
                                                        $rowdata += @(,("          Folder Exclusion List",($Script:htmlsb),"",$htmlwhite))                                           WriteHTMLLine 0 0 "Registry Optimizations"
                                                        $cnt = -1    
                                            $rowdata = @()
     
                                                        ForEach($item in $FSLogixSettingsFolderExclusionList)                                           ForEach($item in $RDSTemplate.Optimization.Registry.RegistryList)
                                                        {                                           {
                                                    $rowdata += @(,(
                                                            $item.DisplayName,$htmlwhite,
                                                            $item.Action,$htmlwhite,
                                                            $item.RegistryName,$htmlwhite,
                                                            $item.RegType,$htmlwhite,
                                                            $item.DWORDValue,$htmlwhite,
                                                            "$($item.HiveType)\$($item.Path)",$htmlwhite)
                                                                $cnt++                                                   )
                                            }
                                                                    
                                            $columnHeaders = @(
                                                    "Registry",($Script:htmlsb),
                                                    "Action",($Script:htmlsb),
                                                                Switch($item.ExcludeFolderCopy)                                                   "Value",($Script:htmlsb),
                                                    "Type",($Script:htmlsb),
                                                    "Data",($Script:htmlsb),
                                                    "Path",($Script:htmlsb)
                                                                {                                           )
                                                                        "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}    
                                                                        "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}                                           $msg = ""
                                                                        "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}                                           $columnWidths = @("200","50","100","100","100","200")
                                                                        "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                                        Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}                                           WriteHTMLLine 0 0 ""
                                                                }                                   }
                                                                    
                                                                If($cnt -eq 0)                                   WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                    If($OPTVisualEffectsEnabled -eq "True")
                                                                {                                   {
                                                                        $rowdata += @(,("               Folder",($Script:htmlsb),"$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack",$htmlwhite))                                           WriteHTMLLine 0 0 "Visual Effects Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Animate controls and elements inside windows",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Animate windows when minimizing and maximizing",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Animations in the taskbar",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Enable Peek",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade or slide menus into view",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade or slide Tooltips into view",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Fade out menu items after clicking",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Save taskbar thumbnail previews",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show shadows under mouse pointer",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show shadows under windows",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show thumbnails instead of icons",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show translucent selection rectangle",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Show window contents while dragging",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Slide open combo boxes",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Smooth edges of screen fonts",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Smooth-scroll list boxes",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Use drop shadows for icon labels on the desktop",$htmlwhite,
                                                    $RDSTemplate.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("275","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                                }                                   }
                                                                Else    
                                    WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                    If($OPTDiskCleanupEnabled -eq "True")
                                                                {                                   {
                                                                        $rowdata += @(,("",($Script:htmlsb),"$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack",$htmlwhite))                                           WriteHTMLLine 0 0 "Disk Cleanup Optimizations"
     
                                            $rowdata = @()
     
                                            $rowdata += @(,(
                                                    "Clean up redundant system files",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)
                                                                }                                           )
     
                                            $rowdata += @(,(
                                                    "Clean up the WinSxS Folder",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)
                                                        }                                           )
     
                                            $rowdata += @(,(
                                                    "Clean up temporary files and logs",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Remove OneDrive",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)
                                            )
     
                                            $rowdata += @(,(
                                                    "Delete users' profiles",$htmlwhite,
                                                    $RDSTemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)
                                            )
     
                                            $columnHeaders = @(
                                                    "Setting",($Script:htmlsb),
                                                    "Enabled",($Script:htmlsb)
                                            )
     
                                            $msg = ""
                                            $columnWidths = @("200","50")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                                }                                   }
 
                                                $rowdata += @(,("     Advanced",($Script:htmlsb),"",$htmlwhite)) <>                                 WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled
                                    If($OPTCustomScriptEnabled -eq "True")
                                    {
                                            $rowdata = @()
                                                $rowdata += @(,("          FSLogix Setting:",($Script:htmlsb),"Value:",$htmlwhite))                                           $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)
                                                $rowdata += @(,("          Access network as computer object",($Script:htmlsb),"$($FSLogixAS_AccessNetworkAsComputerObject)",$htmlwhite))    
                                                $rowdata += @(,("          Custom SDDL for profile directory",($Script:htmlsb),"$($FSLogixAS_ProfileDirSDDL)",$htmlwhite))    
                                                $rowdata += @(,("          Delay between locked VHD(X) retries",($Script:htmlsb),"$($FSLogixAS_LockedRetryInterval)",$htmlwhite))    
                                                $rowdata += @(,("          Delete local profile when loading from VHD",($Script:htmlsb),"$($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)",$htmlwhite))    
                                                $rowdata += @(,("          Diff disk parent folder path",($Script:htmlsb),"$($FSLogixAS_DiffDiskParentFolderPath)",$htmlwhite))    
                                                $rowdata += @(,("          Do not create a folder for new profiles",($Script:htmlsb),"$($FSLogixAS_NoProfileContainingFolder)",$htmlwhite))    
                                                $rowdata += @(,("          Enable Cached mode for Outlook",($Script:htmlsb),"$($FSLogixAS_OutlookCachedMode)",$htmlwhite))    
                                                $rowdata += @(,("          Keep local profiles",($Script:htmlsb),"$($FSLogixAS_KeepLocalDir)",$htmlwhite))    
                                                $rowdata += @(,("          Naming pattern for new VHD(X) files",($Script:htmlsb),"$($FSLogixAS_VHDNamePattern)",$htmlwhite))    
                                                $rowdata += @(,("          Number of locked VHD(X) retries",($Script:htmlsb),"$($FSLogixAS_LockedRetryCount)",$htmlwhite))    
                                                $rowdata += @(,("          Prevent logons with failures",($Script:htmlsb),"$($FSLogixAS_PreventLoginWithFailure)",$htmlwhite))    
                                                $rowdata += @(,("          Prevent logons with temp profiles",($Script:htmlsb),"$($FSLogixAS_PreventLoginWithTempProfile)",$htmlwhite))    
                                                $rowdata += @(,("          Profile folder naming pattern",($Script:htmlsb),"$($FSLogixAS_SIDDirNameMatch)",$htmlwhite))                                           $rowdata += @(,("     Command",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.Command,$htmlwhite))
                                                $rowdata += @(,("          Profile type",($Script:htmlsb),"$($FSLogixAS_ProfileType)",$htmlwhite))    
                                                $rowdata += @(,("          Profile VHD(X) file matching pattern",($Script:htmlsb),"$($FSLogixAS_VHDNameMatch)",$htmlwhite))    
                                                $rowdata += @(,("          Re-attach interval",($Script:htmlsb),"$($FSLogixAS_ReAttachIntervalSeconds)",$htmlwhite))    
                                                $rowdata += @(,("          Re-attach retry limit",($Script:htmlsb),"$($FSLogixAS_ReAttachRetryCount)",$htmlwhite))                                           $rowdata += @(,("     Arguments",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.Arguments,$htmlwhite))
                                                $rowdata += @(,("          Remove duplicate OST files on logoff",($Script:htmlsb),"$($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)",$htmlwhite))    
                                                $rowdata += @(,("          SDDL used when attaching the VHD",($Script:htmlsb),"$($FSLogixAS_AttachVHDSDDL)",$htmlwhite))    
                                                $rowdata += @(,("          Search roaming feature mode",($Script:htmlsb),"$($FSLogixAS_RoamSearch)",$htmlwhite))    
                                                $rowdata += @(,("          Swap SID and username in profile directory names",($Script:htmlsb),"$($FSLogixAS_FlipFlopProfileDirectoryName)",$htmlwhite))                                           $rowdata += @(,("     Initial directory",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.InitDir,$htmlwhite))
                                                $rowdata += @(,("          Temporary folders redirection mode",($Script:htmlsb),"$($FSLogixAS_SetTempToLocalPath)",$htmlwhite))    
                                                $rowdata += @(,("          Use SDDL on creation of SID containing folder",($Script:htmlsb),"$($FSLogixAS_SIDDirSDDL)",$htmlwhite))    
                                                $rowdata += @(,("          User-to-Profile matching pattern",($Script:htmlsb),"$($FSLogixAS_SIDDirNamePattern)",$htmlwhite))                                           $rowdata += @(,("     Username",($Script:htmlsb), $RDSTemplate.Optimization.CustomScript.User,$htmlwhite))
                                                $rowdata += @(,("          VHDX sector size",($Script:htmlsb),"$($FSLogixAS_VHDXSectorSize)",$htmlwhite))    
                                                $rowdata += @(,("          Volume wait time",($Script:htmlsb),"$($FSLogixAS_VolumeWaitTimeMS)",$htmlwhite))    
                                        }    
 
                                        $msg = "User profile" <>                                         $msg = ""
                                        $columnWidths = @("350","325")                                           $columnWidths = @("125","200")
 
                                #> <>                         }
 
                                #License Keys <>                         #License Keys
                                                          
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                        WriteWordLine 4 0 "License Keys"                                   WriteWordLine 4 0 "License Keys"
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        Line 3 "License Keys"                                   Line 2 "License Keys"
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                        #Nothing                                   #Nothing
                                }                           }
                                                          
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                                                          
                                        If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")                                   If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS")
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "License key management type"; Value = "Key Management Service (KMS)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "License key management type"; Value = "Key Management Service (KMS)"; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $ScriptInformation.Add(@{Data = "License key management type"; Value = "Multple Activation Key (MAK)"; }) > $Null                                           $ScriptInformation.Add(@{Data = "License key management type"; Value = "Multple Activation Key (MAK)"; }) > $Null
                                                                                          
                                                $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null                                           $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null
                                                                                          
                                                ForEach($Item in $LicenseKeys)                                           ForEach($Item in $LicenseKeys)
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = "License Key"; Value = $Item.LicenseKey; }) > $Null                                                   $ScriptInformation.Add(@{Data = "License Key"; Value = $Item.LicenseKey; }) > $Null
                                                        $ScriptInformation.Add(@{Data = "Key Limit"; Value = $Item.KeyLimit; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Key Limit"; Value = $Item.KeyLimit; }) > $Null
                                                }                                           }
                                        }                                   }
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")                                   If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS")
                                        {                                   {
                                                Line 4 "License key management type`t: " "Key Management Service (KMS)"                                           Line 3 "License key management type: " "Key Management Service (KMS)"
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 4 "License key management type`t`t`t: " "Multple Activation Key (MAK)"                                           Line 3 "License key management type: " "Multple Activation Key (MAK)"
                                                                                          
                                                $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null                                           $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null
 
                                                ForEach($Item in $LicenseKeys) <>                                         ForEach($Item in $LicenseKeys)
                                                {                                           {
                                                        Line 4 "License Key`t: " $Item.LicenseKey                                                   Line 3 "License Key`t: " $Item.LicenseKey
                                                        Line 4 "Key Limit`t: " $Item.KeyLimit                                                   Line 3 "Key Limit`t: " $Item.KeyLimit
                                                }                                           }
                                        }                                   }
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                        $rowdata = @()                                   $rowdata = @()
                                        If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")                                   If($RDSTemplate.LicenseKeyType.ToString() -eq "KMS")
                                        {                                   {
                                                $columnHeaders = @("License key management type",($Script:htmlsb),"Key Management Service (KMS)",$htmlwhite)                                           $columnHeaders = @("License key management type",($Script:htmlsb),"Key Management Service (KMS)",$htmlwhite)
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $columnHeaders = @("License key management type",($Script:htmlsb),"Multple Activation Key (MAK)",$htmlwhite)                                           $columnHeaders = @("License key management type",($Script:htmlsb),"Multple Activation Key (MAK)",$htmlwhite)
                                                                                          
                                                $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null                                           $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $RDSTemplate.Id -EA 0 4>$Null
 
                                                $cnt = -1 <>                                         $cnt = -1
                                                ForEach($Item in $LicenseKeys)                                           ForEach($Item in $LicenseKeys)
                                                {                                           {
                                                        $rowdata += @(,("License Key",($Script:htmlsb),$Item.LicenseKey,$htmlwhite))                                                   $rowdata += @(,("License Key",($Script:htmlsb),$Item.LicenseKey,$htmlwhite))
                                                        $rowdata += @(,("Key Limit",($Script:htmlsb),$Item.KeyLimit,$htmlwhite))                                                   $rowdata += @(,("Key Limit",($Script:htmlsb),$Item.KeyLimit,$htmlwhite))
                                                }                                           }
                                        }                                   }
 
                                        $msg = "License Keys" <>                                 $msg = "License Keys"
                                        $columnWidths = @("200","275")                                   $columnWidths = @("200","275")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                }                           }
                        }                   }
                }           }
                ElseIf($? -and $Null -eq $VDITemplates)    
                {          
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 0 0 "No VDI Templates found for Site $($Site.Name)"           Write-Verbose "$(Get-Date -Format G): `tOutput RD Session Hosts Scheduler"
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 0 "No VDI Templates found for Site $($Site.Name)"    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 0 0 "No VDI Templates found for Site $($Site.Name)"    
                                WriteHTMLLine 0 0 ""    
                        }    
                }    
                Else    
                {    
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                WriteWordLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"    
                                WriteWordLine 0 0 ""                   WriteWordLine 2 0 "Scheduler"
                        }           }
                        If($Text)           If($Text)
                        {           {
                                Line 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"    
                                Line 0 ""                   Line 1 "Scheduler"
                        }           }
                        If($HTML)           If($HTML)
                        {           {
                                WriteHTMLLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"    
                                WriteHTMLLine 0 0 ""                   WriteHTMLLine 2 0 "Scheduler"
                        }    
                }    
                    
                #Desktops    
                #can't find this    
 
         <>  
        #Remote PCs are not in PoSH    
            
        $GWs = Get-RASGW -Siteid $Site.Id -EA 0 4> $Null           $RDSSchedules = Get-RASRDSSchedule -Siteid $Site.Id -EA 0 4> $Null
 
                Unable to retrieve Gateways for Site $($Site.Name)` <>                 Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)`
 
                        WriteWordLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         WriteWordLine 0 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"
 
                        Line 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         Line 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Gateways for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "Unable to retrieve RD Session Hosts Scheduler for Site $($Site.Name)"
 
        ElseIf($? -and $Null -eq $GWs) <>         ElseIf($? -and $Null -eq $RDSSchedules)
 
                No Gateways retrieved for Site $($Site.Name).` <>                 No RD Session Host Scheduler retrieved for Site $($Site.Name).`
 
                        WriteWordLine 0 0 "No Gateways retrieved for Site $($Site.Name)" <>                         WriteWordLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                        Line 0 "No Gateways retrieved for Site $($Site.Name)" <>                         Line 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                        WriteHTMLLine 0 0 "No Gateways retrieved for Site $($Site.Name)" <>                         WriteHTMLLine 0 0 "No RD Session Host Scheduler retrieved for Site $($Site.Name)"
 
                If($MSWord -or $PDF) <>                 ForEach($RDSSchedule in $RDSSchedules)
 
                        WriteWordLine 2 0 "Gateways" <>                         Write-Verbose "$(Get-Date -Format G): `t`tOutput RD Session Host Scheduler $($RDSSchedule.Name)"
                            $Action = $RDSSchedule.Action
                            If($RDSSChedule.Action -eq "Reboot")
                }                           {
                If($Text)                                   If($RDSSchedule.DrainMode)
                {                                   {
                        Line 1 "Gateways"                                           $Action = "Reboot - Drain Mode"
                }                                   }
                If($HTML)                                   Else
                {                                   {
                        WriteHTMLLine 2 0 "Gateways"                                           $Action = "Reboot"
                }                                   }
                            }
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Gateways"    
                ForEach($GW in $GWs)    
                {    
                        $GWStatus = Get-RASGWStatus -Id $GW.Id -EA 0 4>$Null                           <#If($Action -eq "Reboot - Drain Mode")
                            
                        If(!$?)    
 
                                Write-Warning " <>                                 Switch ($RDSSchedule.CompleteRebootInSecs)
                                `n    
                                Unable to retrieve Gateway Status for Gateway $($GW.Id)`    
                                "    
                                If($MSWord -or $PDF)    
 
                                        WriteWordLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         600             {$TimeDuration = "10 minutes"; Break}
                                            900             {$TimeDuration = "15 minutes"; Break}
                                            1800    {$TimeDuration = "30 minutes"; Break}
                                            2700    {$TimeDuration = "45 minutes"; Break}
                                            3600    {$TimeDuration = "1 hour"; Break}
                                            7200    {$TimeDuration = "2 hours"; Break}
                                            10800   {$TimeDuration = "3 hours"; Break}
                                            Default {$TimeDuration = "Unable to determine Complete in seconds: $($RDSSchedule.CompleteRebootInSecs)"; Break}
 
                                If($Text) <>                                
                                    Switch ($RDSSchedule.ForceRebootAfterSecs)
 
                                        Line 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)" <>                                         900             {$ForceRebootTime = "15 minutes"; Break}
                                            1800    {$ForceRebootTime = "30 minutes"; Break}
                                            2700    {$ForceRebootTime = "45 minutes"; Break}
                                            3600    {$ForceRebootTime = "1 hour"; Break}
                                            7200    {$ForceRebootTime = "2 hours"; Break}
                                            10800   {$ForceRebootTime = "3 hours"; Break}
                                            21600   {$ForceRebootTime = "6 hours"; Break}
                                            43200   {$ForceRebootTime = "12 hours"; Break}
                                            86400   {$ForceRebootTime = "1 day"; Break}
                                            Default {$ForceRebootTime = "Unable to determine Force reboot after seconds: $($RDSSchedule.ForceRebootAfterSecs)"; Break}
 
                                If($HTML) <>  
                                {    
                                        WriteHTMLLine 0 0 "Unable to retrieve Gateway Status for Gateway $($GW.Id)"    
                                }                           }#>
                            <#RDSSchedItem  
                            Dropped Properties      DurationInSecs
                                                                    EndDateTime
                                #unable to retrieve                                                                   DisableAction
                                $GWEnableHSTS            = "Unable to retrieve Gateway Status"    
                                $GWEnableSSL             = "Unable to retrieve Gateway Status"    
                                $GWEnableSSLOnPort       = "Unable to retrieve Gateway Status"    
                                $GWAcceptedSSLVersions   = "Unable to retrieve Gateway Status"    
                                $GWCipherStrength        = "Unable to retrieve Gateway Status"    
                                $GWCipher                = "Unable to retrieve Gateway Status"    
                                $GWCertificates          = "Unable to retrieve Gateway Status"    
                                $GWHSTSMaxage            = "Unable to retrieve Gateway Status"    
                                $GWHSTSIncludeSubdomains = "Unable to retrieve Gateway Status"    
                                $GWHSTSPreload           = "Unable to retrieve Gateway Status"    
                        }                           #>
                        ElseIf($? -and $Null -eq $GWStatus)                           <#ElseIf($Action -eq "Disable")
 
                                Write-Host " <>                                 Switch ($RDSSchedule.DurationInSecs)
                                No Gateway Status retrieved for Gateway $($GW.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
 
                                        WriteWordLine 0 0 "No Gateway Status found for Gateway $($GW.Id)" <>                                         600             {$TimeDuration = "10 minutes"; Break}
                                            900             {$TimeDuration = "15 minutes"; Break}
                                            1800    {$TimeDuration = "30 minutes"; Break}
                                            2700    {$TimeDuration = "45 minutes"; Break}
                                            3600    {$TimeDuration = "1 hour"; Break}
                                            7200    {$TimeDuration = "2 hours"; Break}
                                            10800   {$TimeDuration = "3 hours"; Break}
                                            21600   {$TimeDuration = "6 hours"; Break}
                                            43200   {$TimeDuration = "12 hours"; Break}
                                            86400   {$TimeDuration = "1 day"; Break}
                                            Default {$TimeDuration = "Unable to determine Duration in seconds: $($RDSSchedule.DurationInSecs)"; Break}
 
                                If($Text) <>                                
                                    Switch ($RDSSchedule.DisableAction)
 
                                        Line 0 "No Gateway Status found for Gateway $($GW.Id)" <>                                         "KeepSessionState"                      {$OnDisable = "Keep current sessions state"; Break}
                                            "DisconnectActiveSessions"      {$OnDisable = "Disconnect any active session"; Break}
                                            "ResetAllSessions"                      {$OnDisable = "Reset all sessions"; Break}
                                            Default                                         {$OnDisable = "Unable to determine On disable: $($RDSSchedule.DisableAction)"; Break}
 
                                If($HTML) <>                         }#>
                            
                            Switch ($RDSSchedule.Repeat)
                                {                           {
                                        WriteHTMLLine 0 0 "No Gateway Status found for Gateway $($GW.Id)"                                   Never                   {$Repeat = "Never "; Break}
                                    EveryDay                {$Repeat = "Every day"; Break}
                                    EveryWeek               {$Repeat = "Every week"; Break}
                                    Every2Weeks             {$Repeat = "Every 2 weeks"; Break}
                                    EveryMonth              {$Repeat = "Every month"; Break}
                                    EveryYear               {$Repeat = "Every year"; Break}
                                    SpecificDays    {$Repeat = "Every $($RDSSchedule.SpecificDays)"; Break}
                                    Default                 {$Repeat = "Unable to determine the Repeat: $($RDSSchedule.Repeat)"; Break}
                                }                           }
                                #set all to blank    
                                $GWEnableHSTS            = ""    
                                $GWEnableSSL             = ""    
                                $GWEnableSSLOnPort       = ""    
                                $GWAcceptedSSLVersions   = ""    
                                $GWCipherStrength        = ""    
                                $GWCipher                = ""    
                                $GWCertificates          = ""    
                                $GWHSTSMaxage            = ""    
                                $GWHSTSIncludeSubdomains = ""    
                                $GWHSTSPreload           = ""    
                        }                          
                        Else                           $Target = @()
                            If($RDSSchedule.TargetType -eq "Server")
 
                                If($GW.InheritDefaultSslTlsSettings) <>                                 ForEach($Item in $RDSSchedule.TargetIds)
 
                                        #do we inherit site defaults? <>  
                                        #yes we do, get the default settings for the Site    
                                        #use the Site default settings    
     
                                        $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null                                           $Result = Get-RASRDS -Id $Item -EA 0 4>$Null
 
                                        If($? -and $Null -ne $GWDefaults) <>                                         If($? -and $Null -ne $Result)
 
                                                If($GWDefaults.EnableHSTS) <>                                                 $Target += $Result.Server
                                                {    
                                                        $GWEnableHSTS            = $GWDefaults.EnableHSTS.ToString()    
                                                        $GWHSTSMaxage            = $GWDefaults.HSTSMaxAge.ToString()    
                                                        $GWHSTSIncludeSubdomains = $GWDefaults.HSTSIncludeSubdomains.ToString()    
                                                        $GWHSTSPreload           = $GWDefaults.HSTSPreload.ToString()    
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $GWEnableHSTS = $GWDefaults.EnableHSTS.ToString()                                                   Target += "Unable to find RDS Server for ID $($Item)"
                                                }                                           }
                                                $GWEnableSSL       = $GWDefaults.EnableSSL.ToString()    
                                                $GWEnableSSLOnPort = $GWDefaults.SSLPort.ToString()    
                                                    
                                                Switch ($GWDefaults.MinSSLVersion)    
                                                {    
                                                        "SSLv2"         {$GWAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}    
                                                        "SSLv3"         {$GWAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}    
                                                        "TLSv1"         {$GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}    
                                                        "TLSv1_1"       {$GWAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}    
                                                        "TLSv1_2"       {$GWAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}    
                                                        Default         {$GWAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($GWDefaults.MinSSLVersion)"; Break}    
                                                }                                   }
                                                    
                                                $GWCipherStrength = $GWDefaults.CipherStrength.ToString()    
                                                $GWCipher         = $GWDefaults.Cipher    
                                                    
                                                If($GWDefaults.CertificateId -eq 0)    
                                                {    
                                                        $GWCertificates = "All matching usage"    
                                                }                           }
                                                Else                           ElseIf($RDSSchedule.TargetType -eq "ServerGroup")
                                                {                           {
                                                        $Results = Get-RASCertificate -Id $GWDefaults.CertificateId -EA 0 4>$Null                                   ForEach($Item in $RDSSchedule.TargetIds)
                                                            
                                                        If($? -and $Null -ne $Results)    
                                                        {                                   {
                                                                $GWCertificates = $Results.Name                                           $Result = Get-RASRDSGroup -Id $Item -EA 0 4>$Null
                                                        }                                          
                                                        Else                                           If($? -and $Null -ne $Result)
                                                        {                                           {
                                                                $GWCertificates = "Unable to determin Gateway Certificate: $($GWDefaults.CertificateId)"                                                   $Target += $Result.Name
                                                        }    
                                                }    
 
                                                #unable to retrieve default, use built-in default values <>                                                 Target += "Unable to find RDS Server Group for ID $($Item)"
                                                $GWEnableHSTS          = "False"    
                                                $GWEnableSSL           = "True"    
                                                $GWEnableSSLOnPort     = "443"    
                                                $GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"    
                                                $GWCipherStrength      = "High"    
                                                $GWCipher              = "EECDH:!SSLv2:!SSLv3:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"    
                                                $GWCertificates        = "All matching usage"    
 
                                Else <>  
                                {    
                                        #we don't inherit settings    
                                        #get the settings configured for this GW    
                                        If($GW.EnableHSTS)    
                                        {    
                                                $GWEnableHSTS            = $GW.EnableHSTS.ToString()    
                                                $GWHSTSMaxage            = $GW.HSTSMaxAge.ToString()    
                                                $GWHSTSIncludeSubdomains = $GW.HSTSIncludeSubdomains.ToString()    
                                                $GWHSTSPreload           = $GW.HSTSPreload.ToString()    
                                        }                           }
                                        Else                           Else
                                        {                           {
                                                $GWEnableHSTS = $GW.EnableHSTS.ToString()                                   Target += "Unable to determine Target for TargetType: $($RDSSchedule.TargetType)"
                                        }                           }
                                        $GWEnableSSL       = $GW.EnableSSL.ToString()    
                                        $GWEnableSSLOnPort = $GW.SSLPort.ToString()    
                                                                  
                                        Switch ($GW.MinSSLVersion)                           If($MSWord -or $PDF)
                                        {                           {
                                                "SSLv2"         {$GWAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}                                   WriteWordLine 3 0 "Schedule Name $($RDSSchedule.Name)"
                                                "SSLv3"         {$GWAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                                "TLSv1"         {$GWAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}                                   $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null
                                                "TLSv1_1"       {$GWAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}    
                                                "TLSv1_2"       {$GWAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}    
                                                Default         {$GWAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($GW.MinSSLVersion)"; Break}                                   $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null
                                        }    
                                                                          
                                        $GWCipherStrength = $GW.CipherStrength.ToString()                                   $cnt=-1
                                        $GWCipher         = $GW.Cipher                                   ForEach($Item in $Target)
                                            
                                        If($GW.CertificateId -eq 0)    
                                        {                                   {
                                                $GWCertificates = "All matching usage"    
                                        }                                           $cnt++
                                        Else                                           If($cnt -eq 0)
 
                                                $Results = Get-RASCertificate -Id $GW.CertificateId -EA 0 4>$Null <>                                                 $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null
                                                    
                                                If($? -and $Null -ne $Results)    
                                                {    
                                                        #double replace to remove the < and > from the cert name so it doesn't mess up HTML output    
                                                        $GWCertificates = $Results.Name.Replace("<","").Replace(">","")     
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $GWCertificates = "Unable to determine Gateway Certificate: $($GW.CertificateId)"                                                   $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                                }    
 
                                $GWStatusAgentState = GetRASStatus $GWStatus.AgentState <>  
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 3 0 "Gateways $($GW.Server)"    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Server"; Value = $GW.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Mode"; Value = $GW.GWMode; }) > $Null                                   $ScriptInformation.Add(@{Data = "Repeat"; Value = $Repeat; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $GWStatusAgentState; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $GW.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Certificate"; Value = $GWCertificates; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $GWStatus.LogLevel; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $GW.AdminLastMod; }) > $Null                                   $ScriptInformation.Add(@{Data = "Last modification by"; Value = $RDSSchedule.AdminLastMod; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $GW.TimeLastMod.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Modified on"; Value = $RDSSchedule.TimeLastMod.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $GW.AdminCreate; }) > $Null                                   $ScriptInformation.Add(@{Data = "Created by"; Value = $RDSSchedule.AdminCreate; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $GW.TimeCreate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Created on"; Value = $RDSSchedule.TimeCreate.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $GW.Id.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "ID"; Value = $RDSSchedule.Id.ToString(); }) > $Null
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 250;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        Line 2 "Gateways $($GW.Server)"    
                                        Line 3 "Server`t`t`t: " $GW.Server                                   Line 2 "Name`t`t`t: " $RDSSchedule.Name
                                    Line 2 "Action`t`t`t: " $Action
                                    
                                    $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                        Line 3 "Mode`t`t`t: " $GW.GWMode                                                   Line 2 "Target`t`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 6 "  " $Item
                                            }
                                    }
                                    
                                        Line 3 "Status`t`t`t: " $GWStatusAgentState                                   Line 2 "Start`t`t`t: " $RDSSchedule.StartDateTime
                                    Line 2 "Repeat`t`t`t: " $Repeat
                                        Line 3 "Description`t`t: " $GW.Description                                   Line 2 "Description`t`t: " $RDSSchedule.Description
                                        Line 3 "Certificate`t`t: " $GWCertificates    
                                        Line 3 "Log level`t`t: " $GWStatus.LogLevel    
                                        Line 3 "Last modification by`t: " $GW.AdminLastMod                                   Line 2 "Last modification by`t: " $RDSSchedule.AdminLastMod
                                        Line 3 "Modified on`t`t: " $GW.TimeLastMod.ToString()                                   Line 2 "Modified on`t`t: " $RDSSchedule.TimeLastMod.ToString()
                                        Line 3 "Created by`t`t: " $GW.AdminCreate                                   Line 2 "Created by`t`t: " $RDSSchedule.AdminCreate
                                        Line 3 "Created on`t`t: " $GW.TimeCreate.ToString()                                   Line 2 "Created on`t`t: " $RDSSchedule.TimeCreate.ToString()
                                        Line 3 "ID`t`t`t: " $GW.Id.ToString()                                   Line 2 "ID`t`t`t: " $RDSSchedule.Id.ToString()
                                        Line 0 ""                                   Line 0 ""
                                }                           }
                                If($HTML)                           If($HTML)
                                {                           {
                                        WriteHTMLLine 3 0 "Gateways $($GW.Server)"                                   WriteHTMLLine 3 0 "Schedule Name $($RDSSchedule.Name)"
                                        $rowdata = @()                                   $rowdata = @()
                                        $columnHeaders = @("Server",($Script:htmlsb),$GW.Server,$htmlwhite)                                   $columnHeaders = @("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite)
                                        $rowdata += @(,("Mode",($Script:htmlsb),$GW.GWMode.ToString(),$htmlwhite))                                   $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))
                                    
                                    $cnt=-1
                                    ForEach($Item in $Target)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                        $rowdata += @(,("Status",($Script:htmlsb),$GWStatusAgentState.ToString(),$htmlwhite))                                                   $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                            Else
                                            {
                                        $rowdata += @(,("Description",($Script:htmlsb),$GW.Description,$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    
                                        $rowdata += @(,("Certificate",($Script:htmlsb),$GWCertificates,$htmlwhite))                                   $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime,$htmlwhite))
                                        $rowdata += @(,("Log level",($Script:htmlsb),$GWStatus.LogLevel,$htmlwhite))                                   $rowdata += @(,("Repeat",($Script:htmlsb),$Repeat,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $GW.AdminLastMod,$htmlwhite))                                   $rowdata += @(,("Last modification by",($Script:htmlsb),$RDSSchedule.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $GW.TimeLastMod.ToString(),$htmlwhite))                                   $rowdata += @(,("Modified on",($Script:htmlsb),$RDSSchedule.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $GW.AdminCreate,$htmlwhite))                                   $rowdata += @(,("Created by",($Script:htmlsb),$RDSSchedule.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $GW.TimeCreate.ToString(),$htmlwhite))                                   $rowdata += @(,("Created on",($Script:htmlsb),$RDSSchedule.TimeCreate.ToString(),$htmlwhite))
                                        $rowdata += @(,("ID",($Script:htmlsb),$GW.Id.ToString(),$htmlwhite))                                   $rowdata += @(,("ID",($Script:htmlsb),$RDSSchedule.Id.ToString(),$htmlwhite))
 
                                        $msg = "" <>                                 $msg = ""
                                        $columnWidths = @("300","275")                                   $columnWidths = @("200","275")
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                }                           }
                        }                          
                            #Properties
 
                        Switch ($GW.IPVersion) +-  
                        {    
                                "Version4"              {$IPVersion = "Version 4"; Break}    
                                "Version6"              {$IPVersion = "Version 6"; Break}    
                                "BothVersions"  {$IPVersion = "Both version 4 & 6"; Break}    
                                Default                 {$IPVersion = "Unable to determine IP version: $($GW.IPVersion)"; Break}    
                        }    
                            
                        $GWIPs = $GW.IPs.Split(";")    
                            
                        If($GW.BindV4Addresses -eq "")    
                        {    
                                $GWBindV4Addresses = "All available addresses"    
                        }    
                        Else    
                        {    
                                $GWBindV4Addresses = $GW.BindV4Addresses    
                        }    
     
                        If($GW.OptimizeConnectionIPv4 -eq "<All>")    
                        {    
                                $GWOptimizeV4 = "All available addresses"    
                        }    
                        ElseIf($GW.OptimizeConnectionIPv4 -eq "<None>")    
                        {    
                                $GWOptimizeV4 = "None from the available"    
                        }    
                        Else    
                        {    
                                $GWOptimizeV4 = $GW.OptimizeConnectionIPv4    
                        }    
     
                        If($GW.BindV6Addresses -eq "")    
                        {    
                                $GWBindV6Addresses = "All available addresses"    
                        }    
                        Else    
                        {    
                                $GWBindV6Addresses = $GW.BindV6Addresses    
                        }    
     
                        If($GW.OptimizeConnectionIPv6 -eq "<All>")    
                        {    
                                $GWOptimizeV6 = "All available addresses"    
                        }    
                        ElseIf($GW.OptimizeConnectionIPv6 -eq "<None>")    
                        {    
                                $GWOptimizeV6 = "None from the available"    
                        }    
                        Else    
                        {    
                                $GWOptimizeV6 = $GW.OptimizeConnectionIPv6    
                        }    
     
 
                                $ScriptInformation.Add(@{Data = "Enable RAS Secure Client Gateway in Site"; Value = $GW.Enabled.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Enable Schedule"; Value = $RDSSchedule.Enabled.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Server"; Value = $GW.Server; }) > $Null                                   $ScriptInformation.Add(@{Data = "Name"; Value = $RDSSchedule.Name; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $GW.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Action"; Value = $Action; }) > $Null
                                $ScriptInformation.Add(@{Data = "IP version"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $IPVersion; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $RDSSchedule.Description; }) > $Null
 
                                $cnt = -1 <>                                 $cnt=-1
                                ForEach($Item in $GWIPs)                                   ForEach($Item in $Target)
 
                                        If($cnt -eq 0 ) <>                                         If($cnt -eq 0)
 
                                                $ScriptInformation.Add(@{Data = "     IP(s)"; Value = $Item; }) > $Null <>  
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                                   $ScriptInformation.Add(@{Data = "Target"; Value = $Item; }) > $Null
                                        }    
                                }    
                                    
                                $ScriptInformation.Add(@{Data = "Bind to IP"; Value = ""; }) > $Null    
                                If($GW.IPVersion -ne "Version6")    
                                {    
                                        $ScriptInformation.Add(@{Data = "     Bind to the following IPv4"; Value = $GWBindV4Addresses; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $GWOptimizeV4; }) > $Null    
                                }    
                                If($GW.IPVersion -ne "Version4")    
                                {    
                                        $ScriptInformation.Add(@{Data = "     Bind to the following IPv6"; Value = $GWBindV6Addresses; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $GWOptimizeV6; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Enable RAS Secure Client Gateway in Site: " $GW.Enabled.ToString()    
                                Line 3 "Server`t`t`t`t`t: " $GW.Server    
                                Line 3 "Description`t`t`t`t: " $GW.Description    
                                Line 3 "IP version" ""    
                                Line 4 "Use IP version`t`t`t: " $IPVersion    
                                    
                                $cnt = -1    
                                ForEach($Item in $GWIPs)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0 )    
                                        {    
                                                Line 4 "IP(s)`t`t`t`t: " $Item    
                                        }    
                                        Else    
                                        {    
                                                Line 8 "  " $Item    
                                        }    
                                }    
                                    
                                Line 3 "Bind to IP" ""    
                                If($GW.IPVersion -ne "Version6")    
                                {    
                                        Line 4 "Bind to the following IPv4`t: " $GWBindV4Addresses    
                                        Line 4 "Remove system buffers for`t: " $GWOptimizeV4    
                                }    
                                If($GW.IPVersion -ne "Version4")    
                                {    
                                        Line 4 "Bind to the following IPv6`t: " $GWBindV6Addresses    
                                        Line 4 "Remove system buffers for`t: " $GWOptimizeV6    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Enable RAS Secure Client Gateway in Site",($Script:htmlsb),$GW.Enabled.ToString(),$htmlwhite)    
                                $rowdata += @(,("Server",($Script:htmlsb),$GW.Server,$htmlwhite))    
                                $rowdata += @(,("Description",($Script:htmlsb),$GW.Description,$htmlwhite))    
                                $rowdata += @(,("IP version",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("     Use IP version",($Script:htmlsb),$IPVersion,$htmlwhite))    
                                    
                                $cnt = -1    
                                ForEach($Item in $GWIPs)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0 )    
                                        {    
                                                $rowdata += @(,("     IP(s)",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                $rowdata += @(,("Bind to IP",($Script:htmlsb),"",$htmlwhite))    
                                If($GW.IPVersion -ne "Version6")    
                                {    
                                        $rowdata += @(,("     Bind to the following IPv4",($Script:htmlsb),$GWBindV4Addresses,$htmlwhite))    
                                        $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$GWOptimizeV4,$htmlwhite))    
                                }    
                                If($GW.IPVersion -ne "Version4")    
                                {    
                                        $rowdata += @(,("     Bind to the following IPv6",($Script:htmlsb),$GWBindV6Addresses,$htmlwhite))    
                                        $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$GWOptimizeV6,$htmlwhite))    
                                }    
     
                                $msg = "General"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        #Mode    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Mode"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Mode"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultModeSettings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        $GWMode = $GWDefaults.GWMode.ToString()    
                                        $GWForwardRequests = $GWDefaults.NormalModeForwarding.ToString()    
                                        If($GWMode -eq "Normal")    
                                        {    
                                                $GWServers = $GWDefaults.ForwardHttpServers.Split(";")    
                                        }    
                                        Else    
                                        {    
                                                $GWServers = $GWDefaults.ForwardGatewayServers.Split(";")    
                                        }    
                                    
                                        If($GWDefaults.PreferredPAId -eq 0)    
                                        {    
                                                $GWPreferredPublishingAgent = "Automatically"    
                                        }    
                                        Else    
                                        {    
                                                $GWPreferredPublishingAgent = (Get-RASPA -Id $GWDefaults.PreferredPAId -EA 0 4>$Null).Server    
                                        }    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWMode = "Normal"    
                                        $GWForwardRequests = "False"    
                                        $GWServers = @("localhost:81")    
                                        $GWPreferredPublishingAgent = "Automatically"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWMode = $GW.GWMode.ToString()    
                                $GWForwardRequests = $GW.NormalModeForwarding.ToString()    
                                If($GWMode -eq "Normal")    
                                {    
                                        $GWServers = $GW.ForwardHttpServers.Split(";")    
                                }    
                                Else    
                                {    
                                        $GWServers = $GW.ForwardGatewayServers.Split(";")    
                                }    
                            
                                If($GW.PreferredPAId -eq 0)    
                                {    
                                        $GWPreferredPublishingAgent = "Automatically"    
                                }    
                                Else    
                                {    
                                        $GWPreferredPublishingAgent = (Get-RASPA -Id $GW.PreferredPAId -EA 0 4>$Null).Server    
                                }    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultModeSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Gateway mode"; Value = $GWMode; }) > $Null    
                                    
                                If($GWMode -eq "Normal")    
                                {    
                                        If($GWForwardRequests -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Forward requests to HTTP Server"; Value = $GWForwardRequests; }) > $Null    
                                                    
                                                $cnt = -1    
                                                ForEach($Item in $GWServers)    
                                                {    
                                                        $cnt++    
                                                        $tmparray = $Item.Split(":")    
                                                        $tmpserver = $tmparray[0]    
                                                        $tmpport = $tmparray[1]    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "Server(s)"; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                            
                                        $ScriptInformation.Add(@{Data = "Preferred Publishing Agent"; Value = $GWPreferredPublishingAgent; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)"; Value = $GWForwardRequests; }) > $Null    
                                            
                                        If($GWForwardRequests -eq "True")    
                                        {    
                                                $cnt = -1    
                                                ForEach($Item in $GWServers)    
                                                {    
                                                        $cnt++    
                                                        $tmparray = $Item.Split(":")    
                                                        $tmpserver = $tmparray[0]    
                                                        $tmpport = $tmparray[1]    
                                                        If($cnt -eq 0)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = "Server(s)"; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultModeSettings.ToString()    
                                Line 3 "Gateway mode`t`t`t`t: " $GWMode    
                                If($GWMode -eq "Normal")    
                                {    
                                        Line 3 "Forward requests to HTTP Server`t`t: " $GWForwardRequests    
                                            
                                        $cnt = -1    
                                        ForEach($Item in $GWServers)    
                                        {    
                                                $cnt++    
                                                $tmparray = $Item.Split(":")    
                                                $tmpserver = $tmparray[0]    
                                                $tmpport = $tmparray[1]    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"    
                                                }    
                                                Else    
                                                {    
                                                        Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"    
                                                }    
                                        }    
                                            
                                        Line 3 "Preferred Publishing Agent`t`t: " $GWPreferredPublishingAgent    
                                }    
                                Else    
                                {    
                                        Line 3 "Forward requests to next "    
                                        Line 3 "RAS Secure Client Gateway"    
                                        Line 3 "in chain (cascaded firewall)`t`t: " $GWForwardRequests    
                                            
                                        $cnt = -1    
                                        ForEach($Item in $GWServers)    
                                        {    
                                                $cnt++    
                                                $tmparray = $Item.Split(":")    
                                                $tmpserver = $tmparray[0]    
                                                $tmpport = $tmparray[1]    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"    
                                                }    
                                                Else    
                                                {    
                                                        Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"    
                                                }    
                                        }    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultModeSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Gateway mode",($Script:htmlsb),$GWMode,$htmlwhite))    
                                If($GWMode -eq "Normal")    
                                {    
                                        $rowdata += @(,("Forward requests to HTTP Server",($Script:htmlsb),$GWForwardRequests,$htmlwhite))    
                                            
                                        $cnt = -1    
                                        ForEach($Item in $GWServers)    
                                        {    
                                                $cnt++    
                                                $tmparray = $Item.Split(":")    
                                                $tmpserver = $tmparray[0]    
                                                $tmpport = $tmparray[1]    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))    
                                                }    
                                        }    
                                            
                                        $rowdata += @(,("Preferred Publishing Agent",($Script:htmlsb),$GWPreferredPublishingAgent,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)",($Script:htmlsb),$GWForwardRequests,$htmlwhite))    
                                            
                                        $cnt = -1    
                                        ForEach($Item in $GWServers)    
                                        {    
                                                $cnt++    
                                                $tmparray = $Item.Split(":")    
                                                $tmpserver = $tmparray[0]    
                                                $tmpport = $tmparray[1]    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))    
                                                }    
                                        }    
                                }    
     
                                $msg = "Mode"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Network    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Network"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Network"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultNetworkSettings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        $GWEnableRASSecureClientGatewayPort             = $GWDefaults.EnableGWPort.ToString()    
                                        $GWRASSecureClientGatewayPort                   = $GWDefaults.GWPort.ToString()    
                                        $GWEnableRDPPort                                = $GWDefaults.EnableRDP.ToString()    
                                        $GWRDPPort                                      = $GWDefaults.RDPPort.ToString()    
                                        $GWEnableBroadcastRASSecureClientGatewayAddress = $GWDefaults.Broadcast.ToString()    
                                        $GWEnableRDPUPDDataTunneling                    = $GWDefaults.EnableRDPUDP.ToString()    
                                        $GWEnableClientManagerPort                      = $GWDefaults.EnableClientManagerPort.ToString()    
                                        $GWClientManagerPort                            = "20009"    
                                        $GWEnableRDPDOSAttackFilter                     = $GWDefaults.DOSPro.ToString()    
                                        $GWCipherPreference                             = $GWDefaults.CipherPreference.ToString()    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWEnableRASSecureClientGatewayPort             = "True"    
                                        $GWRASSecureClientGatewayPort                   = "80"    
                                        $GWEnableRDPPort                                = "False"    
                                        $GWEnableBroadcastRASSecureClientGatewayAddress = "True"    
                                        $GWEnableRDPUPDDataTunneling                    = "True"    
                                        $GWEnableClientManagerPort                      = "True"    
                                        $GWClientManagerPort                            = "20009"    
                                        $GWEnableRDPDOSAttackFilter                     = "True"    
                                        $GWCipherPreference                             = "True"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWEnableRASSecureClientGatewayPort             = $GW.EnableGWPort.ToString()    
                                $GWRASSecureClientGatewayPort                   = $GW.GWPort.ToString()    
                                $GWEnableRDPPort                                = $GW.EnableRDP.ToString()    
                                $GWRDPPort                                      = $GW.RDPPort.ToString()    
                                $GWEnableBroadcastRASSecureClientGatewayAddress = $GW.Broadcast.ToString()    
                                $GWEnableRDPUPDDataTunneling                    = $GW.EnableRDPUDP.ToString()    
                                $GWEnableClientManagerPort                      = $GW.EnableClientManagerPort.ToString()    
                                $GWClientManagerPort                            = "20009"    
                                $GWEnableRDPDOSAttackFilter                     = $GW.DOSPro.ToString()    
                                $GWCipherPreference                             = $GW.CipherPreference.ToString()    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultNetworkSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RAS Secure Client Gateway Port"; Value = $GWEnableRASSecureClientGatewayPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "RAS Secure Client Gateway Port"; Value = $GWRASSecureClientGatewayPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RDP Port"; Value = $GWEnableRDPPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "RDP Port"; Value = $GWRDPPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable Broadcast RAS Secure Client Gateway Address"; Value = $GWEnableBroadcastRASSecureClientGatewayAddress; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RDP UDP Data Tunneling"; Value = $GWEnableRDPUPDDataTunneling; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable Client Manager Port"; Value = $GWEnableClientManagerPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Client Manager Port"; Value = $GWClientManagerPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable RDP DOS Attack Filter"; Value = $GWEnableRDPDOSAttackFilter; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultNetworkSettings.ToString()    
                                Line 3 "Enable RAS Secure Client Gateway Port`t: " $GWEnableRASSecureClientGatewayPort    
                                Line 3 "RAS Secure Client Gateway Port`t`t: " $GWRASSecureClientGatewayPort    
                                Line 3 "Enable RDP Port`t`t`t`t: " $GWEnableRDPPort    
                                Line 3 "RDP Port`t`t`t`t: " $GWRDPPort    
                                Line 3 "Enable Broadcast RAS Secure "    
                                Line 3 "Client Gateway Address`t`t`t: " $GWEnableBroadcastRASSecureClientGatewayAddress    
                                Line 3 "Enable RDP UDP Data Tunneling`t`t: " $GWEnableRDPUPDDataTunneling    
                                Line 3 "Enable Client Manager Port`t`t: " $GWEnableClientManagerPort    
                                Line 3 "Client Manager Port`t`t`t: " $GWClientManagerPort    
                                Line 3 "Enable RDP DOS Attack Filter`t`t: " $GWEnableRDPDOSAttackFilter    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultNetworkSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Enable RAS Secure Client Gateway Port",($Script:htmlsb),$GWEnableRASSecureClientGatewayPort,$htmlwhite))    
                                $rowdata += @(,("RAS Secure Client Gateway Port",($Script:htmlsb),$GWRASSecureClientGatewayPort,$htmlwhite))    
                                $rowdata += @(,("Enable RDP Port",($Script:htmlsb),$GWEnableRDPPort,$htmlwhite))    
                                $rowdata += @(,("RDP Port",($Script:htmlsb),$GWRDPPort,$htmlwhite))    
                                $rowdata += @(,("Enable Broadcast RAS Secure Client Gateway Address",($Script:htmlsb),$GWEnableBroadcastRASSecureClientGatewayAddress,$htmlwhite))    
                                $rowdata += @(,("Enable RDP UDP Data Tunneling",($Script:htmlsb),$GWEnableRDPUPDDataTunneling,$htmlwhite))    
                                $rowdata += @(,("Enable Client Manager Port",($Script:htmlsb),$GWEnableClientManagerPort,$htmlwhite))    
                                $rowdata += @(,("Client Manager Port",($Script:htmlsb),$GWClientManagerPort,$htmlwhite))    
                                $rowdata += @(,("Enable RDP DOS Attack Filter",($Script:htmlsb),$GWEnableRDPDOSAttackFilter,$htmlwhite))    
     
                                $msg = "Network"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #SSL/TLS    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "SSL/TLS"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "SSL/TLS"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultSslTlsSettings.ToString(); }) > $Null    
     
                                If($GWEnableHSTS -eq "False")    
                                {    
                                        $ScriptInformation.Add(@{Data = "HSTS is off"; Value = ""; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "HSTS is on"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Enforce HTTP strict transport security (HSTS)"; Value = $GWEnableHSTS; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Browser caache time"; Value = "$GWHSTSMaxage months"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Include subdomains"; Value = $GWHSTSIncludeSubdomains; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Preload"; Value = $GWHSTSPreload; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "Enable SSL"; Value = $GWEnableSSL; }) > $Null    
                                $ScriptInformation.Add(@{Data = "on Port"; Value = $GWEnableSSLOnPort; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Accepted SSL Versions"; Value = $GWAcceptedSSLVersions; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Cipher Strength"; Value = $GWCipherStrength; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Cipher"; Value = $GWCipher; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Use ciphers according to server preference"; Value = $GWCipherPreference; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Certificates"; Value = $GWCertificates; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t  : " $GW.InheritDefaultSslTlsSettings.ToString()    
     
                                If($GWEnableHSTS -eq "False")    
                                {    
                                        Line 3 "HSTS is off"    
                                }    
                                Else    
                                {    
                                        Line 3 "HSTS is on"    
                                        Line 3 "Enforce HTTP strict transport security`t  : " $GWEnableHSTS    
                                        Line 3 "Browser caache time`t`t`t  : " "$GWHSTSMaxage months"    
                                        Line 3 "Include subdomains`t`t`t  : " $GWHSTSIncludeSubdomains    
                                        Line 3 "Preload`t`t`t`t`t  : " $GWHSTSPreload    
                                }    
     
                                Line 3 "Enable SSL`t`t`t`t  : " $GWEnableSSL    
                                Line 3 "on Port`t`t`t`t`t  : " $GWEnableSSLOnPort    
                                Line 3 "Accepted SSL Versions`t`t`t  : " $GWAcceptedSSLVersions    
                                Line 3 "Cipher Strength`t`t`t`t  : " $GWCipherStrength    
                                Line 3 "Cipher`t`t`t`t`t  : " $GWCipher    
                                Line 3 "Use ciphers according to server preference: " $GWCipherPreference    
                                Line 3 "Certificates`t`t`t`t  : " $GWCertificates    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultSslTlsSettings.ToString(),$htmlwhite)    
     
                                If($GWEnableHSTS -eq "False")    
                                {    
                                        $rowdata += @(,("HSTS is off",($Script:htmlsb),"",$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("HSTS is on",($Script:htmlsb),,$htmlwhite))    
                                        $rowdata += @(,("Enforce HTTP strict transport security (HSTS)",($Script:htmlsb),$GWEnableHSTS,$htmlwhite))    
                                        $rowdata += @(,("Browser caache time",($Script:htmlsb),"$GWHSTSMaxage months",$htmlwhite))    
                                        $rowdata += @(,("Include subdomains",($Script:htmlsb),$GWHSTSIncludeSubdomains,$htmlwhite))    
                                        $rowdata += @(,("Preload",($Script:htmlsb),$GWHSTSPreload,$htmlwhite))    
                                }    
     
                                $rowdata += @(,("Enable SSL",($Script:htmlsb),$GWEnableSSL,$htmlwhite))    
                                $rowdata += @(,("on Port",($Script:htmlsb),$GWEnableSSLOnPort,$htmlwhite))    
                                $rowdata += @(,("Accepted SSL Versions",($Script:htmlsb),$GWAcceptedSSLVersions,$htmlwhite))    
                                $rowdata += @(,("Cipher Strength",($Script:htmlsb),$GWCipherStrength,$htmlwhite))    
                                $rowdata += @(,("Cipher",($Script:htmlsb),$GWCipher,$htmlwhite))    
                                $rowdata += @(,("Use ciphers according to server preference",($Script:htmlsb),$GWCipherPreference,$htmlwhite))    
                                $rowdata += @(,("Certificates",($Script:htmlsb),$GWCertificates,$htmlwhite))    
     
                                $msg = "SSL/TLS"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #HTML5    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "HTML5"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "HTML5"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultHTML5Settings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        $GWEnableHTML5Client = $GWDefaults.EnableHTML5.ToString()    
                                            
                                        Switch($GWDefaults.LaunchMethod)    
                                        {    
                                                "ParallelsClientAndHTML5"       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break}    
                                                "ParallelsClient"                       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client"; Break}    
                                                "HTML5"                                         {$GWLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break}    
                                                Default                                         {$GWLaunchSessionsUsing = "Unable to determine Launch sessions using: $($GWDefaults.LaunchMethod)"; Break}    
                                        }    
                                            
                                        Switch ($GWDefaults.FileTransferMode)    
                                        {    
                                                "Bidirectional"         {$GWFileTransferMode = "Bidirectional"; Break}    
                                                "Disabled"                      {$GWFileTransferMode = "Disabled"; Break}    
                                                "ClientToServer"        {$GWFileTransferMode = "Client to server only"; Break}    
                                                "ServerToClient"        {$GWFileTransferMode = "Server to client only"; Break}    
                                                Default                         {$GWFileTransferMode = "Unable to determine File Transfer mode: $($GWDefaults.FileTransferMode)"; Break}    
                                        }    
     
                                        Switch ($GWDefaults.ClipboardDirection)    
                                        {    
                                                "Bidirectional"         {$GWClipboardTransferMode = "Bidirectional"; Break}    
                                                "Disabled"                      {$GWClipboardTransferMode = "Disabled"; Break}    
                                                "ClientToServer"        {$GWClipboardTransferMode = "Client to server only"; Break}    
                                                "ServerToClient"        {$GWClipboardTransferMode = "Server to client only"; Break}    
                                                Default                         {$GWClipboardTransferMode = "Unable to determine Clipboard mode: $($GWDefaults.ClipboardDirection)"; Break}    
                                        }    
     
                                        $GWAllowLaunchMethod          = $GWDefaults.AllowLaunchMethod.ToString()    
                                        $GWAllowAppsInNewTab          = $GWDefaults.AllowAppsInNewTab.ToString()    
                                        $GWUsePreWin2000LoginFormat   = $GWDefaults.UsePreWin2000LoginFormat.ToString()    
                                        $GWAllowEmbed                 = $GWDefaults.AllowEmbed.ToString()    
                                        $GWAllowFileTransfer          = $GWDefaults.AllowFileTransfer.ToString()    
                                        $GWAllowClipboard             = $GWDefaults.AllowClipboard.ToString()    
                                        $GWAllowCORS                  = $GWDefaults.AllowCORS    
                                        $GWAllowedDomainsForCORS      = $GWDefaults.AllowedDomainsForCORS    
                                        $GWBrowserCacheTimeInMonths   = $GWDefaults.BrowserCacheTimeInMonths    
                                        $GWEnableAlternateNLBHostname = $GWDefaults.EnableAlternateNLBHost.ToString()    
                                        $GWAlternameNLBHostname       = $GWDefaults.AlternateNLBHost    
                                        $GWEnableAlternateNLBPort     = $GWDefaults.EnableAlternateNLBPort.ToString()    
                                        $GWAlternateNLBPort           = $GWDefaults.AlternateNLBPort.ToString()    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWEnableHTML5Client          = "True"    
                                        $GWLaunchSessionsUsing        = "Launch apps with Parallels CLient & Fallback to HTML5"    
                                        $GWAllowLaunchMethod          = "True"    
                                        $GWAllowAppsInNewTab          = "False"    
                                        $GWUsePreWin2000LoginFormat   = "True"    
                                        $GWAllowEmbed                 = "False"    
                                        $GWAllowFileTransfer          = "True"    
                                        $GWAllowClipboard             = "True"    
                                        $GWAllowCORS                  = "False"    
                                        $GWAllowedDomainsForCORS      = @()    
                                        $GWBrowserCacheTimeInMonths   = 12    
                                        $GWEnableAlternateNLBHostname = "False"    
                                        $GWAlternameNLBHostname       = ""    
                                        $GWEnableAlternateNLBPort     = "False"    
                                        $GWAlternateNLBPort           = "8443"    
                                        $GWClipboardTransferMode      = "Bidirectional"    
                                        $GWClipboardTransferMode      = "Bidirectional"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWEnableHTML5Client = $GW.EnableHTML5.ToString()    
                                    
                                Switch($GW.LaunchMethod)    
                                {    
                                        "ParallelsClientAndHTML5"       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break}    
                                        "ParallelsClient"                       {$GWLaunchSessionsUsing = "Launch apps with Parallels Client"; Break}    
                                        "HTML5"                                         {$GWLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break}    
                                        Default                                         {$GWLaunchSessionsUsing = "Unable to determine Launch sessions using: $($GW.LaunchMethod)"; Break}    
                                }    
                                    
                                Switch ($GW.FileTransferMode)    
                                {    
                                        "Bidirectional"         {$GWFileTransferMode = "Bidirectional"; Break}    
                                        "Disabled"                      {$GWFileTransferMode = "Disabled"; Break}    
                                        "ClientToServer"        {$GWFileTransferMode = "Client to server only"; Break}    
                                        "ServerToClient"        {$GWFileTransferMode = "Server to client only"; Break}    
                                        Default                         {$GWFileTransferMode = "Unable to determine File Transfer mode: $($GW.FileTransferMode)"; Break}    
                                }    
     
                                Switch ($GW.ClipboardDirection)    
                                {    
                                        "Bidirectional"         {$GWClipboardTransferMode = "Bidirectional"; Break}    
                                        "Disabled"                      {$GWClipboardTransferMode = "Disabled"; Break}    
                                        "ClientToServer"        {$GWClipboardTransferMode = "Client to server only"; Break}    
                                        "ServerToClient"        {$GWClipboardTransferMode = "Server to client only"; Break}    
                                        Default                         {$GWClipboardTransferMode = "Unable to determine Clipboard mode: $($GW.ClipboardDirection)"; Break}    
                                }    
     
                                $GWAllowLaunchMethod          = $GW.AllowLaunchMethod.ToString()    
                                $GWAllowAppsInNewTab          = $GW.AllowAppsInNewTab.ToString()    
                                $GWUsePreWin2000LoginFormat   = $GW.UsePreWin2000LoginFormat.ToString()    
                                $GWAllowEmbed                 = $GW.AllowEmbed.ToString()    
                                $GWAllowFileTransfer          = $GW.AllowFileTransfer    
                                $GWAllowClipboard             = $GW.AllowClipboard    
                                $GWAllowCORS                  = $GW.AllowCORS    
                                $GWAllowedDomainsForCORS      = $GW.AllowedDomainsForCORS    
                                $GWBrowserCacheTimeInMonths   = $GW.BrowserCacheTimeInMonths    
                                $GWEnableAlternateNLBHostname = $GW.EnableAlternateNLBHost.ToString()    
                                $GWAlternameNLBHostname       = $GW.AlternateNLBHost    
                                $GWEnableAlternateNLBPort     = $GW.EnableAlternateNLBPort.ToString()    
                                $GWAlternateNLBPort           = $GW.AlternateNLBPort.ToString()    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultHTML5Settings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable HTML5 Client"; Value = $GWEnableHTML5Client; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Client"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $GWLaunchSessionsUsing; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $GWAllowLaunchMethod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $GWAllowAppsInNewTab; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $GWUsePreWin2000LoginFormat; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow embedding of Parallels HTML5 Client into other web pages"; Value = $GWAllowEmbed; }) > $Null    
     
                                $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $GWAllowFileTransfer.ToString(); }) > $Null    
                                If($GWAllowFileTransfer)    
                                {    
                                        $ScriptInformation.Add(@{Data = "          Direction"; Value = $GWFileTransferMode; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $GWAllowClipboard.ToString(); }) > $Null    
                                If($GWAllowClipboard)    
                                {    
                                        $ScriptInformation.Add(@{Data = "          Clipboard Redirection"; Value = $GWClipboardTransferMode; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $GWAllowCORS.ToString(); }) > $Null    
                                If($GWAllowCORS)    
                                {    
                                        $cnt=-1    
                                        ForEach($Domain in $GWAllowedDomainsForCORS)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "     Allow domains"; Value = $Domain; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $Domain; }) > $Null    
                                                }    
                                        }    
                                        $ScriptInformation.Add(@{Data = "     Browser cache time"; Value = "$($GWBrowserCacheTimeInMonths.ToString()) months"; }) > $Null    
                                }    
     
                                $ScriptInformation.Add(@{Data = "Network Load Balancer access"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Use alternate hostname"; Value = $GWEnableAlternateNLBHostname; }) > $Null    
                                If($GWEnableAlternateNLBHostname -eq "True")    
                                {    
                                        $ScriptInformation.Add(@{Data = ""; Value = $GWAlternameNLBHostname; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "     Use alternate port"; Value = $GWEnableAlternateNLBPort; }) > $Null    
                                If($GWEnableAlternateNLBPort -eq "True")    
                                {    
                                        $ScriptInformation.Add(@{Data = ""; Value = $GWAlternateNLBPort; }) > $Null    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t`t: " $GW.InheritDefaultHTML5Settings.ToString()    
                                Line 3 "Enable HTML5 Client`t`t`t`t: " $GWEnableHTML5Client    
                                Line 3 "Client" ""    
                                Line 4 "Launch sessions using`t`t`t: " $GWLaunchSessionsUsing    
                                Line 4 "Allow user to select a launch method`t: " $GWAllowLaunchMethod    
                                Line 4 "Allow opening applications in a new tab`t: " $GWAllowAppsInNewTab    
                                Line 4 "Use Pre Windows 2000 login format`t: " $GWUsePreWin2000LoginFormat    
                                Line 4 "Allow embedding of Parallels HTML5"    
                                Line 4 "Client into other web pages`t`t: " $GWAllowEmbed    
     
                                Line 4 "Allow file transfer command`t`t: " $GWAllowFileTransfer.ToString()    
                                If($GW.AllowFileTransfer)    
                                {    
                                        Line 5 "Direction: " $GWFileTransferMode    
                                }    
     
                                Line 4 "Allow clipboard command`t`t`t: " $GWAllowClipboard.ToString()    
                                If($GW.AllowClipboard)    
                                {    
                                        Line 5 "Clipboard Redirection: " $GWClipboardTransferMode    
                                }    
     
                                Line 4 "Allow cross-origin resource sharing`t: " $GWAllowCORS.ToString()    
                                If($GWAllowCORS)    
                                {    
                                        $cnt=-1    
                                        ForEach($Domain in $GWAllowedDomainsForCORS)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 7 "Allow domains   : " $Domain    
                                                }    
                                                Else    
                                                {    
                                                        Line 9 "  " $Domain    
                                                }    
                                        }    
                                        Line 6 "Browser cache time      : " "$($GWBrowserCacheTimeInMonths.ToString()) months"    
                                }    
     
                                Line 3 "Network Load Balancer access" ""    
                                Line 4 "Use alternate hostname`t`t: " $GWEnableAlternateNLBHostname    
                                If($GWEnableAlternateNLBHostname -eq "True")    
                                {    
                                        Line 8 $GWAlternameNLBHostname    
                                }    
                                Line 4 "Use alternate port`t`t: " $GWEnableAlternateNLBPort    
                                If($GWEnableAlternateNLBPort -eq "True")    
                                {    
                                        Line 8 $GWAlternateNLBPort    
                                }    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultHTML5Settings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Enable HTML5 Client",($Script:htmlsb),$GWEnableHTML5Client,$htmlwhite))    
                                $rowdata += @(,("Client",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$GWLaunchSessionsUsing,$htmlwhite))    
                                $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$GWAllowLaunchMethod,$htmlwhite))    
                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb),$GWAllowAppsInNewTab,$htmlwhite))    
                                $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb),$GWUsePreWin2000LoginFormat,$htmlwhite))    
                                $rowdata += @(,("     Allow embedding of Parallels HTML5 Client into other web pages",($Script:htmlsb),$GWAllowEmbed,$htmlwhite))    
     
                                $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$GWAllowFileTransfer.ToString(),$htmlwhite))    
                                If($GW.AllowFileTransfer)    
                                {    
                                        $rowdata += @(,("          Direction",($Script:htmlsb),$GWFileTransferMode,$htmlwhite))    
                                }    
     
                                $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$GWAllowClipboard.ToString(),$htmlwhite))    
                                If($GW.AllowClipboard)    
                                {    
                                        $rowdata += @(,("          Clipboard Redirection",($Script:htmlsb),$GWClipboardTransferMode,$htmlwhite))    
                                }    
     
                                $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$GWAllowCORS.ToString(),$htmlwhite))    
                                If($GWAllowCORS)    
                                {    
                                        $cnt=-1    
                                        ForEach($Domain in $GWAllowedDomainsForCORS)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("     Allow domains",($Script:htmlsb),$Domain,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$Domain,$htmlwhite))    
                                                }    
                                        }    
                                        $rowdata += @(,("     Browser cache time",($Script:htmlsb),"$($GWBrowserCacheTimeInMonths.ToString()) months",$htmlwhite))    
                                }    
     
                                $rowdata += @(,("Network Load Balancer access",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("     Use alternate hostname",($Script:htmlsb),$GWEnableAlternateNLBHostname,$htmlwhite))    
                                If($GWEnableAlternateNLBHostname -eq "True")    
                                {    
                                        $rowdata += @(,("",($Script:htmlsb),$GWAlternameNLBHostname,$htmlwhite))    
                                }    
                                $rowdata += @(,("     Use alternate port",($Script:htmlsb),$GWEnableAlternateNLBPort,$htmlwhite))    
                                If($GWEnableAlternateNLBPort -eq "True")    
                                {    
                                        $rowdata += @(,("",($Script:htmlsb),$GWAlternateNLBPort,$htmlwhite))    
                                }    
     
                                $msg = "HTML5"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Wyse    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Wyse"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Wyse"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultWyseSettings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        $GWEnableWyse          = $GWDefaults.EnableWyseSupport.ToString()    
                                        $GWDisableWyseCertWarn = $GWDefaults.DisableWyseCertWarn.ToString()    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWEnableWyse          = "True"    
                                        $GWDisableWyseCertWarn = "False"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWEnableWyse          = $GW.EnableWyseSupport.ToString()    
                                $GWDisableWyseCertWarn = $GW.DisableWyseCertWarn.ToString()    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultWyseSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Enable Wyse ThinOS Support"; Value = $GWEnableWyse; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Do not warn if server certificate is not verified"; Value = $GWDisableWyseCertWarn; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Inherit default settings`t`t`t : " $GW.InheritDefaultWyseSettings.ToString()    
                                Line 3 "Enable Wyse ThinOS Support`t`t`t : " $GWEnableWyse    
                                Line 3 "Do not warn if server certificate is not verified: " $GWDisableWyseCertWarn    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultWyseSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Enable Wyse ThinOS Support",($Script:htmlsb),$GWEnableWyse,$htmlwhite))    
                                $rowdata += @(,("Do not warn if server certificate is not verified",($Script:htmlsb),$GWDisableWyseCertWarn,$htmlwhite))    
     
                                $msg = "Wyse"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        #Security    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Security"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Security"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($GW.InheritDefaultSecuritySettings)    
                        {    
                                #do we inherit site defaults?    
                                #yes we do, get the default settings for the Site    
                                #use the Site default settings    
     
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
                                {    
                                        If($GWDefaults.SecurityMode -eq "AllowAllExcept")    
                                        {    
                                                $GWAllow = "AllowAllExcept"    
                                                $MACAddresses = @()    
                                                ForEach($Item in $GWDefaults.MACAllowExcept)    
                                                {    
                                                        $MACAddresses += $Item    
                                                }    
                                        }    
                                        Else    
                                        {    
                                                $GWAllow = "AllowOnly"    
                                                $MACAddresses = @()    
                                                ForEach($Item in $GWDefaults.MACAllowOnly)    
                                                {    
                                                        $MACAddresses += $Item    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        #unable to retrieve default, use built-in default values    
                                        $GWAllow = "AllowAllExcept"    
                                        $MACAddresses = @()    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                If($GW.SecurityMode -eq "AllowAllExcept")    
                                {    
                                        $GWAllow = "AllowAllExcept"    
                                        $MACAddresses = @()    
                                        ForEach($Item in $GW.MACAllowExcept)    
                                        {    
                                                $MACAddresses += $Item    
                                        }    
                                }    
                                Else    
                                {    
                                        $GWAllow = "AllowOnly"    
                                        $MACAddresses = @()    
                                        ForEach($Item in $GW.MACAllowOnly)    
                                        {    
                                                $MACAddresses += $Item    
                                        }    
                                }    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultSecuritySettings.ToString(); }) > $Null    
                                If($GWAllow -eq "AllowAllExcept")    
                                {    
                                        $ScriptInformation.Add(@{Data = "Allow all except"; Value = ""; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Allow only"; Value = ""; }) > $Null    
                                }    
                                $cnt =-1    
                                ForEach($Item in $MACAddresses)    
                                {    
                                        $cnt++    
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "MAC Address"; Value = $Item; }) > $Null    
 
                                Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultSecuritySettings.ToString() <>                                 Line 3 "Enable Schedule`t`t`t: " $RDSSchedule.Enabled.ToString()
                                If($GWAllow -eq "AllowAllExcept")                                   Line 3 "Name`t`t`t`t: " $RDSSchedule.Name
                                {                                   Line 3 "Action`t`t`t`t: " $Action
                                        Line 3 "Allow all except"                                   Line 3 "Description`t`t`t: " $RDSSchedule.Description
                                }                                  
                                Else    
                                {    
                                        Line 3 "Allow only"    
                                }    
                                $cnt =-1                                   $cnt=-1
                                ForEach($Item in $MACAddresses)                                   ForEach($Item in $Target)
 
                                                Line 3 "MAC Address`t`t`t`t: " $Item <>                                                 Line 3 "Target`t`t`t`t: " $Item
 
                                                Line 8 "  " $Item <>                                                 Line 7 "  " $Item
 
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultSecuritySettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Enable schedule",($Script:htmlsb),$RDSSchedule.Enabled.ToString(),$htmlwhite)
                                If($GWAllow -eq "AllowAllExcept")    
                                {    
                                        $rowdata += @(,("Allow all except",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Name",($Script:htmlsb),$RDSSchedule.Name,$htmlwhite))
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Allow only",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Action",($Script:htmlsb),$Action,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$RDSSchedule.Description,$htmlwhite))
                                }                                  
                                $cnt =-1                                   $cnt=-1
                                ForEach($Item in $MACAddresses)                                   ForEach($Item in $Target)
 
                                                $rowdata += @(,("MAC Address",($Script:htmlsb),$Item,$htmlwhite)) <>                                                 $rowdata += @(,("Target",($Script:htmlsb),$Item,$htmlwhite))
 
  <>                                 
                                $msg = "Security"                                   $msg = "General"
                                $columnWidths = @("300","275")                                   $columnWidths = @("200","275")
 
                        #Web <>                         #Trigger
 
                                WriteWordLine 4 0 "Web" <>                                 WriteWordLine 4 0 "Trigger"
 
                                Line 2 "Web" <>                                 Line 2 "Trigger"
 
                        If($GW.InheritDefaultWebSettings) <>                         If($MSWord -or $PDF)
 
                                #do we inherit site defaults? <>                                 $ScriptInformation = New-Object System.Collections.ArrayList
                                #yes we do, get the default settings for the Site                                   $ScriptInformation.Add(@{Data = "Date"; Value = $RDSSchedule.StartDateTime.ToShortDateString(); }) > $Null
                                #use the Site default settings                                   $ScriptInformation.Add(@{Data = "Start"; Value = $RDSSchedule.StartDateTime.ToShortTimeString(); }) > $Null
                                    <#If($Action -eq "Reboot - Drain Mode")
                                $GWDefaults = Get-RASGWDefaultSettings -SiteId $Site.Id -EA 0 4>$Null    
                                    
                                If($? -and $Null -ne $GWDefaults)    
 
                                        $GWDefaultURL = $GWDefaults.WebRequestsURL <>                                         $ScriptInformation.Add(@{Data = "Complete in"; Value = $TimeDuration  ; }) > $Null
                                        $GWWebCookie = $GWDefaults.WebCookie    
 
                                Else <>                                 ElseIf($Action -eq "Disable")
 
                                        #unable to retrieve default, use built-in default values <>  
                                        $GWDefaultURL = "https://%hostname%/RASHTML5Gateway"    
                                        $GWWebCookie = "ASP.NET_SessionId"    
                                }    
                        }    
                        Else    
                        {    
                                #we don't inherit settings    
                                #get the settings configured for this GW    
                                $GWDefaultURL = $GW.WebRequestsURL    
                                $GWWebCookie = $GW.WebCookie    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $GW.InheritDefaultWebSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Default URL"; Value = $GWDefaultURL; }) > $Null                                           $ScriptInformation.Add(@{Data = "Duration"; Value = $TimeDuration; }) > $Null
                                    }#>
                                $ScriptInformation.Add(@{Data = "Web cookie"; Value = $GWWebCookie; }) > $Null                                   $ScriptInformation.Add(@{Data = "Recur"; Value = $Repeat; }) > $Null
 
                                Line 3 "Inherit default settings`t`t: " $GW.InheritDefaultWebSettings.ToString() <>                                 Line 3 "Date`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortDateString()
                                Line 3 "Default URL`t`t`t`t: " $GWDefaultURL                                   Line 3 "Start`t`t`t`t: " $RDSSchedule.StartDateTime.ToShortTimeString()
                                Line 3 "Web cookie`t`t`t`t: " $GWWebCookie                                   <#If($Action -eq "Reboot - Drain Mode")
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {                                   {
                                $rowdata = @()                                           Line 3 "Complete in`t`t`t: " $TimeDuration
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$GW.InheritDefaultWebSettings.ToString(),$htmlwhite)    
                                $rowdata += @(,("Default URL",($Script:htmlsb),$GWDefaultURL,$htmlwhite))    
                                $rowdata += @(,("Web cookie",($Script:htmlsb),$GWWebCookie,$htmlwhite))    
     
                                $msg = "Web"    
                                $columnWidths = @("300","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }                                   }
                }                                   ElseIf($Action -eq "Disable")
        }    
     
        $PAs = Get-RASPA -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {                                   {
                Write-Warning "                                           Line 3 "Duration`t`t`t: " $TimeDuration
                `n    
                Unable to retrieve Publishing Agents for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"    
                }                                   }#>
                If($Text)                                   Line 3 "Recur`t`t`t`t: " $Repeat
                {                                   Line 0 ""
                        Line 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"    
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agents for Site $($Site.Name)"                                   $rowdata = @()
                }                                   $columnHeaders = @("Date",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortDateString(),$htmlwhite)
        }                                   $rowdata += @(,("Start",($Script:htmlsb),$RDSSchedule.StartDateTime.ToShortTimeString(),$htmlwhite))
        ElseIf($? -and $Null -eq $PAs)                                   <#If($Action -eq "Reboot - Drain Mode")
        {                                   {
                Write-Host "                                           $rowdata += @(,("Complete in",($Script:htmlsb),$TimeDuration,$htmlwhite))
                No Publishing Agents retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)"    
                }                                   }
                If($Text)                                   ElseIf($Action -eq "Disable")
                {                                   {
                        Line 0 "No Publishing Agents retrieved for Site $($Site.Name)"                                           $rowdata += @(,("Duration",($Script:htmlsb),$TimeDuration,$htmlwhite))
                }                                   }#>
                If($HTML)                                   $rowdata += @(,("Recur",($Script:htmlsb),$Repeat,$htmlwhite))
                {    
                        WriteHTMLLine 0 0 "No Publishing Agents retrieved for Site $($Site.Name)"                                   $msg = "Trigger"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                }                           }
        }    
        Else                           #Options
        {                           
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 2 0 "Publishing Agents"                                   WriteWordLine 4 0 "Options"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 1 "Publishing Agents"                                   Line 2 "Options"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 2 0 "Publishing Agents"                                   #Nothing
                }                           }
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing Agents"    
                ForEach($PA in $PAs)    
                {    
                        $PAStatus = Get-RASPAStatus -Id $PA.Id -EA 0 4>$Null    
 
                        If(!$?) <>  
                        {    
                                Write-Warning "    
                                `n    
                                Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)`    
                                "    
                                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                                {                           {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                        WriteWordLine 0 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"                                   $ScriptInformation.Add(@{Data = "Send message before schedule is triggered"; Value = ""; }) > $Null
                                }    
                                If($Text)                                   If($RDSSChedule.Messages.Count -gt 0)
 
                                        Line 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)" <>                                         ForEach($Item in $RDSSChedule.Messages)
                                }                                           {
                                If($HTML)                                                   Switch ($Item.SendMsgSecs)
                                {                                                   {
                                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Agent Status for Publishing Agent $($PA.Id)"                                                           900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}
                                                            1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}
                                                            2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}
                                                            3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}
                                                            7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}
                                                            10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}
                                                            Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}
                                }                                                   }
                                                    
                                                    $ScriptInformation.Add(@{Data = "Enabled"; Value = $Item.Enabled.ToString(); }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Body"; Value = $Item.Message; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Title"; Value = $Item.MessageTitle; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Time"; Value = $MsgTime; }) > $Null
                        }                                           }
                        ElseIf($? -and $Null -eq $PAStatus)    
                        {    
                                Write-Host "    
                                No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)`    
                                " -ForegroundColor White    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 0 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)"    
 
                                If($Text) <>  
                                    If($Action -ne "Disable")
 
                                        Line 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)" <>                                         $ScriptInformation.Add(@{Data = "Enable Drain Mode"; Value = $RDSSchedule.DrainMode.ToString(); }) > $Null
 
                                If($HTML) <>                                 <#If($Action -eq "Reboot - Drain Mode")
 
                                        WriteHTMLLine 0 0 "No Publishing Agent Status retrieved for Publishing Agent $($PA.Id)" <>                                         $ScriptInformation.Add(@{Data = "Force server reboot after"; Value = $ForceRebootTime; }) > $Null
                                }                                   }#>
                        }                                   If($Action -like "Reboot*")
                        Else    
                        {    
                                If($PA.Standby -eq $False)    
 
                                        $PAPriority = "Master" <>                                         $ScriptInformation.Add(@{Data = "Enforce schedule for currently inactive RD Session Host"; Value = $RDSSchedule.EnforceOnInactive.ToString(); }) > $Null
 
                                Else <>                                 If($Action -eq "Disable")
 
                                        $PAPriority = "Standby" <>                                         $ScriptInformation.Add(@{Data = "On disable"; Value = $OnDisable; }) > $Null
 
  +-  
                                $PAStatusAgentState = GetRASStatus $PAStatus.AgentState    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 3 0 "Publishing Agents $($PA.Server)"    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Server"; Value = $PA.Server; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Priority"; Value = $PAPriority; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $PAStatusAgentState; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Log level"; Value = $PAStatus.LogLevel; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PA.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $PA.TimeLastMod.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $PA.AdminCreate; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $PA.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $PA.Id.ToString(); }) > $Null    
 
                                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                        -Columns Data,Value `                                   -Columns Data,Value `
                                        -List `                                   -List `
                                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                                        $Table = $Null                                   $Table = $Null
                                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                                }                           }
                                If($Text)                           If($Text)
                                {                           {
                                        Line 2 "Publishing Agents $($PA.Server)"                                   Line 3 "Send message before schedule is triggered"
                                    
                                    If($RDSSChedule.Messages.Count -gt 0)
                                    {
                                            ForEach($Item in $RDSSChedule.Messages)
                                            {
                                                    Switch ($Item.SendMsgSecs)
                                                    {
                                                            900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}
                                                            1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}
                                                            2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}
                                                            3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}
                                                            7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}
                                                            10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}
                                                            Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}
                                                    }
                                                    
                                                    Line 3 "Enabled`t`t`t`t: " $Item.Enabled.ToString()
                                        Line 3 "Server`t`t`t: " $PA.Server                                                   Line 3 "Body`t`t`t`t: " $Item.Message
                                        Line 3 "Priority`t`t: " $PAPriority    
                                        Line 3 "Status`t`t`t: " $PAStatusAgentState                                                   Line 3 "Title`t`t`t`t: " $Item.MessageTitle
                                                    Line 3 "Time`t`t`t`t: " $MsgTime
                                            }
                                    }
     
                                    If($Action -ne "Disable")
                                    {
                                            Line 3 "Enable Drain Mode`t`t: " $RDSSchedule.DrainMode.ToString()
                                    }
                                    <#If($Action -eq "Reboot - Drain Mode")
                                    {
                                            Line 3 "Force server reboot after`t: " $ForceRebootTime
                                    }#>
                                    If($Action -like "Reboot*")
                                    {
                                            Line 3 "Enforce schedule for currently"
                                            Line 3 "inactive RD Session Host`t: " $RDSSchedule.EnforceOnInactive.ToString()
                                    }
                                    If($Action -eq "Disable")
                                    {
                                            Line 3 "On disable`t`t`t: " $OnDisable
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Send message before schedule is triggered",($Script:htmlsb),"",$htmlwhite)
                                    
                                    If($RDSSChedule.Messages.Count -gt 0)
                                    {
                                            ForEach($Item in $RDSSChedule.Messages)
                                            {
                                                    Switch ($Item.SendMsgSecs)
                                                    {
                                                            900             {$MsgTime = "15 minutes $($Item.SendMsgWhen)"; Break}
                                                            1800    {$MsgTime = "30 minutes $($Item.SendMsgWhen)"; Break}
                                                            2700    {$MsgTime = "45 minutes $($Item.SendMsgWhen)"; Break}
                                                            3600    {$MsgTime = "1 hour $($Item.SendMsgWhen)"; Break}
                                                            7200    {$MsgTime = "2 hours $($Item.SendMsgWhen)"; Break}
                                                            10800   {$MsgTime = "3 hours $($Item.SendMsgWhen)"; Break}
                                                            Default {$MsgTime = "Unable to determine scheduled message Time: $($Item.SendMsgSecs)"; Break}
                                                    }
                                                    
                                                    $rowdata += @(,("Enabled",($Script:htmlsb),$Item.Enabled.ToString(),$htmlwhite))
                                                    $rowdata += @(,("Body",($Script:htmlsb),$Item.Message,$htmlwhite))
                                                    $rowdata += @(,("Title",($Script:htmlsb),$Item.MessageTitle,$htmlwhite))
                                                    $rowdata += @(,("Time",($Script:htmlsb),$MsgTime,$htmlwhite))
                                            }
                                    }
     
                                    If($Action -ne "Disable")
                                    {
                                            $rowdata += @(,("Enable Drain Mode",($Script:htmlsb),$RDSSchedule.DrainMode.ToString(),$htmlwhite))
                                    }
                                    <#If($Action -eq "Reboot - Drain Mode")
                                    {
                                            $rowdata += @(,("Force server reboot after",($Script:htmlsb),$ForceRebootTime,$htmlwhite))
                                    }#>
                                    If($Action -like "Reboot*")
                                    {
                                            $rowdata += @(,("Enforce schedule for currently inactive RD Session Host",($Script:htmlsb),$RDSSchedule.EnforceOnInactive.ToString(),$htmlwhite))
                                    }
                                    If($Action -eq "Disable")
                                    {
                                            $rowdata += @(,("On disable",($Script:htmlsb),$OnDisable,$htmlwhite))
                                    }
     
                                    $msg = "Options"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
     
            #VDI
            Write-Verbose "$(Get-Date -Format G): Output VDI"
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "VDI"
            }
            If($Text)
            {
                    Line 1 "VDI"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "VDI"
            }
     
            $VDIHosts = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve VDI for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve VDI for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $VDIHosts)
            {
                    Write-Host "
                    No VDI retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No VDI retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No VDI retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No VDI retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    Write-Verbose "$(Get-Date -Format G): `tOutput VDI Pools"
                    #Pools
                    
                    If($MSWord -or $PDF)
                    {
                            $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null
                            If($? -and $Null -ne $VDIPools)
                            {
                                    ForEach($VDIPool in $VDIPools)
                                    {
                                            WriteWordLine 3 0 "Pool $($VDIPool.Name)"
     
                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null 
                                            
                                            If($? -and $Null -ne $VDIPoolMembers)
                                            {
                                                    $VDIPoolMember = $VDIPoolMembers[0]
                                                    Switch($VDIPoolMember.Type)
                                                    {
                                                            "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                            "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                            "Desktop"                               {$MemberType = "Guest"; Break}
                                                            "GUEST"                                 {$MemberType = "Guest"; Break}
                                                            "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                            "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                            "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                            "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                            Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                    }
                                            }
                                            Else
                                            {
                                                    $MemberType = ""
                                            }
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Name"; Value = $VDIPool.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Enabled"; Value = $VDIPool.Enabled.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $VDIPool.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Members type"; Value = $MemberType; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDIPool.AdminLastMod; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDIPool.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $VDIPool.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $VDIPool.TimeCreate.ToString(); }) > $Null
                                            
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                            
                                            #General
                                            
                                            WriteWordLine 4 0 "General"
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Enable pool in site"; Value = $VDIPool.Enabled.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Name"; Value = $VDIPool.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $VDIPool.Description; }) > $Null
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                            
                                            #Members
                                            
                                            WriteWordLine 4 0 "Members"
     
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            If($VDIPool.Members.Count -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Members"; Value = "There are no pool members"; }) > $Null
                                            }
                                            Else
                                            {
                                                    ForEach($Item in $VDIPool.Members)
                                                    {
                                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $VDIPoolMembers)
                                                            {
                                                                    ForEach($VDIPoolMember in $VDIPoolMembers)
                                                                    {
                                                                            Switch($VDIPoolMember.Type)
                                                                            {
                                                                                    "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                                                    "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                                                    "Desktop"                               {$MemberType = "Guest"; Break}
                                                                                    "GUEST"                                 {$MemberType = "Guest"; Break}
                                                                                    "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                                    "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                                                    "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                                                    "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                                    Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                            }
                                                                            $ScriptInformation.Add(@{Data = "Name: $($VDIPoolMember.Name)"; Value = "Type: $MemberType"; }) > $Null
                                                                    }
                                                            }
                                                            ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "Members"; Value = "None found"; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "Members"; Value = "Unable to retrieve"; }) > $Null
                                                            }
                                                    }
                                            }
     
                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "WildCard"; Value = $VDIPool.WildCard; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                            }
                            ElseIf($? -and $Null -eq $VDIPools)
                            {
                                    WriteWordLine 0 0 "No VDI Pools found for Site $($Site.Name)"
                            }
                            Else
                            {
                                    WriteWordLine 0 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"
                            }
                            WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null
                            If($? -and $Null -ne $VDIPools)
                            {
                                    ForEach($VDIPool in $VDIPools)
                                    {
                                            Line 2 "Pool $($VDIPool.Name)"
                                            
                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null 
                                            
                                            If($? -and $Null -ne $VDIPoolMembers)
                                            {
                                                    $VDIPoolMember = $VDIPoolMembers[0]
                                                    Switch($VDIPoolMember.Type)
                                                    {
                                                            "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                            "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                            "Desktop"                               {$MemberType = "Guest"; Break}
                                                            "GUEST"                                 {$MemberType = "Guest"; Break}
                                                            "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                            "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                            "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                            "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                            Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                    }
                                            }
                                            Else
                                            {
                                                    $MemberType = ""
                                            }
     
                                        Line 3 "Log level`t`t: " $PAStatus.LogLevel                                           Line 3 "Name`t`t`t: " $VDIPool.Name
                                            Line 3 "Enabled`t`t`t: " $VDIPool.Enabled.ToString()
                                            Line 3 "Description`t`t: " $VDIPool.Description
                                            Line 3 "Members type`t`t: " $MemberType
                                        Line 3 "Last modification by`t: " $PA.AdminLastMod                                           Line 3 "Last modification by`t: " $VDIPool.AdminLastMod
                                        Line 3 "Modified on`t`t: " $PA.TimeLastMod.ToString()                                           Line 3 "Modified on`t`t: " $VDIPool.TimeLastMod.ToString()
                                        Line 3 "Created by`t`t: " $PA.AdminCreate                                           Line 3 "Created by`t`t: " $VDIPool.AdminCreate
                                        Line 3 "Created on`t`t: " $PA.TimeCreate.ToString()                                           Line 3 "Created on`t`t: " $VDIPool.TimeCreate.ToString()
                                            Line 0 ""
                                            
                                            #General
                                            Line 3 "General"
                                        Line 3 "ID`t`t`t: " $PA.Id.ToString()                                           Line 4 "Enable pool in site`t: " $VDIPool.Enabled.ToString()
                                            Line 4 "Name`t`t`t: " $VDIPool.Name
                                            Line 4 "Description`t`t: " $VDIPool.Description
 
  -+                                         
                                            #Members
                                            
                                            Line 3 "Members"
                                            If($VDIPool.Members.Count -eq 0)
                                            {
                                                    Line 4 "Members: " "There are no pool members"
                                            }
                                            Else
                                            {
                                                    ForEach($Item in $VDIPool.Members)
                                                    {
                                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $VDIPoolMembers)
                                                            {
                                                                    ForEach($VDIPoolMember in $VDIPoolMembers)
                                                                    {
                                                                            Switch($VDIPoolMember.Type)
                                                                            {
                                                                                    "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                                                    "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                                                    "Desktop"                               {$MemberType = "Guest"; Break}
                                                                                    "GUEST"                                 {$MemberType = "Guest"; Break}
                                                                                    "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                                    "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                                                    "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                                                    "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                                    Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                            }
                                                                            Line 4 "Name: $($VDIPoolMember.Name) " "Type: $MemberType"
                                                                    }
                                                            }
                                                            ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                            {
                                                                    Line 4 "Members: " "None found"
                                                            }
                                                            Else
                                                            {
                                                                    Line 4 "Members: " "Unable to retrieve"
                                                            }
                                                    }
                                            }
                                            Line 0 ""
                                            Line 4 "WildCard: " $VDIPool.WildCard
                                            Line 0 ""
 
  <>                                 Line 0 ""
                            }
                            ElseIf($? -and $Null -eq $VDIPools)
                            {
                                    Line 0 "No VDI Pools found for Site $($Site.Name)"
                            }
                            Else
                            {
                                    Line 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"
                            }
                            Line 0 ""
                    }
                                If($HTML)                   If($HTML)
                    {
                            $VDIPools = Get-RASVDIPool -SiteId $Site.Id -EA 0 4>$Null
                            If($? -and $Null -ne $VDIPools)
                            {
                                    ForEach($VDIPool in $VDIPools)
 
                                        WriteHTMLLine 3 0 "Publishing Agents $($PA.Server)" <>                                         WriteHTMLLine 3 0 "Pool $($VDIPool.Name)"
                    
                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null 
                                            
                                            If($? -and $Null -ne $VDIPoolMembers)
                                            {
                                                    $VDIPoolMember = $VDIPoolMembers[0]
                                                    Switch($VDIPoolMember.Type)
                                                    {
                                                            "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                            "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                            "Desktop"                               {$MemberType = "Guest"; Break}
                                                            "GUEST"                                 {$MemberType = "Guest"; Break}
                                                            "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                            "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                            "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                            "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                            Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                    }
                                            }
                                            Else
                                            {
                                                    $MemberType = ""
                                            }
     
 
                                        $columnHeaders = @("Server",($Script:htmlsb),$PA.Server,$htmlwhite) <>                                         $columnHeaders = @("Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite)
                                        $rowdata += @(,("Priority",($Script:htmlsb),$PAPriority,$htmlwhite))                                           $rowdata += @(,("Enabled",($Script:htmlsb),$VDIPool.Enabled.ToString(),$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$PAStatusAgentState,$htmlwhite))                                           $rowdata += @(,("Description",($Script:htmlsb),$VDIPool.Description,$htmlwhite))
                                        $rowdata += @(,("Log level",($Script:htmlsb),$PAStatus.LogLevel,$htmlwhite))                                           $rowdata += @(,("Members type: ",($Script:htmlsb),$MemberType,$htmlwhite))
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $PA.AdminLastMod,$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $VDIPool.AdminLastMod,$htmlwhite))
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $PA.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("Modified on",($Script:htmlsb), $VDIPool.TimeLastMod.ToString(),$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $PA.AdminCreate,$htmlwhite))                                           $rowdata += @(,("Created by",($Script:htmlsb), $VDIPool.AdminCreate,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $PA.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("Created on",($Script:htmlsb), $VDIPool.TimeCreate.ToString(),$htmlwhite))
                                            
                                            ForEach($Item in $VDIPool.Members)
                                            {
                                                    $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                    
                                                    If($? -and $Null -ne $VDIPoolMembers)
                                                    {
                                                            $cnt = -1
                                                            ForEach($VDIPoolMember in $VDIPoolMembers)
                                                            {
                                                                    Switch($VDIPoolMember.Type)
                                                                    {
                                                                            "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                                            "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                                            "Desktop"                               {$MemberType = "Guest"; Break}
                                                                            "GUEST"                                 {$MemberType = "Guest"; Break}
                                                                            "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                            "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                                            "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                                            "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                            Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                    }
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("    Members",($Script:htmlsb),"Name: $($VDIPoolMember.Name) Type: $MemberType",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"Name: $($VDIPoolMember.Name) Type: $MemberType",$htmlwhite))
                                                                    }
                                                            }
                                                    }
                                                    ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                    {
                                        $rowdata += @(,("ID",($Script:htmlsb),$PA.Id.ToString(),$htmlwhite))                                                           $rowdata += @(,("    Members",($Script:htmlsb),"None found",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("    Members",($Script:htmlsb),"Unable to retrieve",$htmlwhite))
                                                    }
                                            }
 
  -+  
                                            #General
                                    
                                            $rowdata = @()
                                            $columnHeaders = @("Enable pool in site",($Script:htmlsb),$VDIPool.Enabled.ToString(),$htmlwhite)
                                            $rowdata += @(,("Name",($Script:htmlsb),$VDIPool.Name,$htmlwhite))
                                            $rowdata += @(,("Description",($Script:htmlsb),$VDIPool.Description,$htmlwhite))
                                            
                                            $msg = "General"
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
     
                                            #Members
                            
                                            $rowdata = @()
                                            If($VDIPool.Members.Count -eq 0)
                                            {
                                                    $columnHeaders = @("Members",($Script:htmlsb),"There are no pool members",$htmlwhite)
                                            }
                                            Else
                                            {
                                                    ForEach($Item in $VDIPool.Members)
                                                    {
                                                            $VDIPoolMembers = Get-RASVDIPoolMember -SiteId $Site.Id -VDIPoolName $VDIPool.Name -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $VDIPoolMembers)
                                                            {
                                                                    $cnt = -1
                                                                    ForEach($VDIPoolMember in $VDIPoolMembers)
                                                                    {
                                                                            Switch($VDIPoolMember.Type)
                                                                            {
                                                                                    "ALLGUESTINHOST"                {$MemberType = "All desktops in Provider"; Break}
                                                                                    "AllDesktopsInProvider" {$MemberType = "All desktops in Provider"; Break}
                                                                                    "Desktop"                               {$MemberType = "Guest"; Break}
                                                                                    "GUEST"                                 {$MemberType = "Guest"; Break}
                                                                                    "NATIVEPOOL"                    {$MemberType = "Native Pool"; Break}
                                                                                    "TEMPLATEDesktop"               {$MemberType = "Template Desktop"; Break}
                                                                                    "TEMPLATEGUEST"                 {$MemberType = "Template Desktop"; Break}
                                                                                    "UNKNOWN"                               {$MemberType = "Unknown"; Break}
                                                                                    Default                                 {$MemberType = "Unable to determine Pool Member Type: $($VDIPoolMember.Type)"; Break}
                                                                            }
                                                                            $cnt++
                                                                            If($cnt -eq 0)
                                                                            {
                                                                                    $columnHeaders = @("Name: $($VDIPoolMember.Name)",($Script:htmlsb),"Type: $MemberType",$htmlwhite)
                                                                            }
                                                                            Else
                                                                            {
                                                                                    $rowdata += @(,("Name: $($VDIPoolMember.Name)",($Script:htmlsb),"Type: $MemberType",$htmlwhite))
                                                                            }
                                                                    }
                                                            }
                                                            ElseIf($? -and $Null -eq $VDIPoolMembers)
                                                            {
                                                                    $rowdata += @(,("Members",($Script:htmlsb),"None found",$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("Members",($Script:htmlsb),"Unable to retrieve",$htmlwhite))
                                                            }
                                                    }
                                            }
                                            
                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("WildCard",($Script:htmlsb),$VDIPool.WildCard,$htmlwhite))
     
                                            $msg = "Members"
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
 
  <>                         ElseIf($? -and $Null -eq $VDIPools)
                            {
                                    WriteHTMLLine 0 0 "No VDI Pools found for Site $($Site.Name)"
                            }
                            Else
                            {
                                    WriteHTMLLine 0 0 "Unable to retrieve VDI Pools for Site $($Site.Name)"
                            }
                            WriteHTMLLine 0 0 ""
                    }
                                          
                    Write-Verbose "$(Get-Date -Format G): `tOutput VDI Templates"
                    #Templates
                    
                    $VDITemplates = Get-RASVDITemplate -SiteId $Site.Id -EA 0 4>$Null | Where-Object {$_.TemplateType -eq "VDIDesktop"}
                    If(!$?)
                    {
                            Write-Warning "
                            `n
                            Unable to retrieve VDI Templates for Site $($Site.Name)`
                            "
 
                                WriteWordLine 4 0 "Properties" <>                                 WriteWordLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
 
  <>                                 Line 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 0 0 "Unable to retrieve VDI Templates for Site $($Site.Name)"
                            }
                    }
                    ElseIf($? -and $Null -eq $VDITemplates)
                    {
                                Line 2 "Properties"                           Write-Host "
                            No VDI Templates retrieved for Site $($Site.Name).`
                            " -ForegroundColor White
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 0 0 "No VDI Templates retrieved for Site $($Site.Name)"
 
  -+                         If($Text)
                            {
                                    Line 0 "No VDI Templates retrieved for Site $($Site.Name)"
                            }
 
  <>                                 WriteHTMLLine 0 0 "No VDI Templates retrieved for Site $($Site.Name)"
                            }
                    }
                    Else
                    {
                            ForEach($VDITemplate in $VDITemplates)
                            {
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Template $($VDITemplate.Name)"
                                    }
                                    If($Text)
                                    {
                                            Line 2 "Template $($VDITemplate.Name)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 3 0 "Template $($VDITemplate.Name)"
                                    }
                                    
                                    $TemplateProvider = Get-RASProvider -Id $RDSTemplate.ProviderId -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $TemplateProvider)
                                    {
                                            $TemplateProviderName = $TemplateProvider.Server
                                            $TemplateProviderType = GetVDIType $TemplateProvider.Type
                                    }
                                    Else
                                    {
                                            $TemplateProviderName = ""
                                            $TemplateProviderType = ""
                                    }
                                    
                                    $TemplateVM = Get-RASVM -Id $VDITemplate.VMId -ProviderId $VDITemplate.ProviderId -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $TemplateVM)
                                    {
                                #Nothing                                           <#
                                                    Values          Description
                                                    Unknown         The VM is in the 'Unknown' state
                                                    On                  The VM is powered on.
                                                    Off                 The VM is powered off
                                                    Paused          The VM is already, or in the process of being, suspended
                                                    CloningFailed   Failed to clone the VM.
                                                    CloningCanceled VM cloning was cancelled
                                            #>
                                            Switch($TemplateVM.State)
                                            {
                                                    "Unknown"                       {$TemplatePowerState = "Unknown"; Break}
                                                    "On"                            {$TemplatePowerState = "Powered on"; Break}
                                                    "Off"                           {$TemplatePowerState = "Powered off"; Break}
                                                    "Paused"                        {$TemplatePowerState = "Paused"; Break}
                                                    "CloningFailed"         {$TemplatePowerState = "Cloning failed"; Break}
                                                    "CloningCanceled"       {$TemplatePowerState = "Cloning canceled"; Break}
                                                    Default                         {$TemplatePowerState = "Unable to determine template VM power state: $($TemplateVM.State)"; Break}
                        }                                           }
                                    }
                                    Else
                                    {
                                            $TemplatePowerState = "Unknown"
                                    }
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                $ScriptInformation.Add(@{Data = "Enable Server in Site"; Value = $PA.Enabled.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Name"; Value = $VDITemplate.Name; }) > $Null
                                            #$ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null
                                $ScriptInformation.Add(@{Data = "Server"; Value = $PA.Server; }) > $Null                                           $ScriptInformation.Add(@{Data = "Power state"; Value = $TemplatePowerState; }) > $Null
                                $ScriptInformation.Add(@{Data = "IP"; Value = $PA.IP; }) > $Null                                           #$ScriptInformation.Add(@{Data = "Agent status"; Value = "Can't find"; }) > $Null
                                            #$ScriptInformation.Add(@{Data = "Distribution"; Value = "Can't find"; }) > $Null
                                $ScriptInformation.Add(@{Data = "Alternative IPs"; Value = $PA.AlternativeIPs; }) > $Null                                           $ScriptInformation.Add(@{Data = "Provider"; Value = $TemplateProviderName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Provider type"; Value = $TemplateProviderType; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PA.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Last modification by"; Value = $VDITemplate.AdminLastMod; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $VDITemplate.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $VDITemplate.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $VDITemplate.TimeCreate.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Standby"; Value = $PA.Standby.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "ID"; Value = $VDITemplate.Id.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                            Line 3 "Name: " $VDITemplate.Name
                                            #Line 3 "Status`t`t`t: " "Can't find"
                                            Line 3 "Power state`t`t: " $TemplatePowerState
                                            #Line 3 "Agent status`t`t: " "Can't find"
                                            #Line 3 "Distribution`t`t: " "Can't find"
                                Line 3 "Enable Server in Site`t: " $PA.Enabled.ToString()                                           Line 3 "Provider`t`t: " $TemplateProviderName
                                Line 3 "Server`t`t`t: " $PA.Server                                           Line 3 "Provider type`t`t: " $TemplateProviderType
                                Line 3 "IP`t`t`t: " $PA.IP                                           Line 3 "Last modification by`t: " $VDITemplate.AdminLastMod
                                            Line 3 "Modified on`t`t: " $VDITemplate.TimeLastMod.ToString()
                                Line 3 "Alternative IPs`t`t: " $PA.AlternativeIPs                                           Line 3 "Created by`t`t: " $VDITemplate.AdminCreate
                                Line 3 "Description`t`t: " $PA.Description                                           Line 3 "Created on`t`t: " $VDITemplate.TimeCreate.ToString()
                                Line 3 "Standby`t`t`t: " $PA.Standby.ToString()                                           Line 3 "ID`t`t`t: " $VDITemplate.Id.ToString()
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Enable Server in Site",($Script:htmlsb),$PA.Enabled.ToString(),$htmlwhite)                                           $columnHeaders = @("Name",($Script:htmlsb),$VDITemplate.Name,$htmlwhite)
                                            #$rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite))
                                $rowdata += @(,("Server",($Script:htmlsb),$PA.Server,$htmlwhite))                                           $rowdata += @(,("Power state",($Script:htmlsb),$TemplatePowerState,$htmlwhite))
                                $rowdata += @(,("IP",($Script:htmlsb),$PA.IP,$htmlwhite))                                           #$rowdata += @(,("Agent status",($Script:htmlsb),"Can't find",$htmlwhite))
                                            #$rowdata += @(,("Distribution",($Script:htmlsb),"Can't find",$htmlwhite))
                                $rowdata += @(,("Alternative IPs",($Script:htmlsb),$PA.AlternativeIPs,$htmlwhite))                                           $rowdata += @(,("Provider",($Script:htmlsb),$TemplateProviderName,$htmlwhite))
                                            $rowdata += @(,("Provider type",($Script:htmlsb),$TemplateProviderType,$htmlwhite))
                                $rowdata += @(,("Description",($Script:htmlsb),$PA.Description,$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $VDITemplate.AdminLastMod,$htmlwhite))
                                            $rowdata += @(,("Modified on",($Script:htmlsb), $VDITemplate.TimeLastMod.ToString(),$htmlwhite))
                                            $rowdata += @(,("Created by",($Script:htmlsb), $VDITemplate.AdminCreate,$htmlwhite))
                                            $rowdata += @(,("Created on",($Script:htmlsb), $VDITemplate.TimeCreate.ToString(),$htmlwhite))
                                $rowdata += @(,("Standby",($Script:htmlsb),$PA.Standby.ToString(),$htmlwhite))                                           $rowdata += @(,("Id",($Script:htmlsb),$VDITemplate.Id.ToString(),$htmlwhite))
 
                                $msg = "Properties" <>                                         $msg = ""
                                $columnWidths = @("200","275")                                           $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
                }    
        }    
            
        #Enrollment Servers - not in PoSH    
            
        #HALB    
        If([version]$Script:RASVersion -ge [version]"18.3")    
        {    
                $HALBs = Get-RASHALB -Siteid $Site.Id -EA 0 4> $Null     
 
                If(!$?) <>  
                {    
                        Write-Warning "    
                        `n    
                        Unable to retrieve HALBs for Site $($Site.Name)`    
                        "    
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"    
                        }    
                        If($Text)    
                        {    
                                Line 0 "Unable to retrieve HALBs for Site $($Site.Name)"    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"    
                        }    
                }    
                ElseIf($? -and $Null -eq $HALBs)    
                {    
                        Write-Host "                                   #Properties
                        No HALBs retrieved for Site $($Site.Name).`    
                        " -ForegroundColor White    
                        If($MSWord -or $PDF)    
                        {                                   
                                WriteWordLine 0 0 "No HALBs retrieved for Site $($Site.Name)"    
                        }    
                        If($Text)    
                        {    
                                Line 0 "No HALBs retrieved for Site $($Site.Name)"    
                        }    
                        If($HTML)    
                        {    
                                WriteHTMLLine 0 0 "No HALBs retrieved for Site $($Site.Name)"    
                        }    
                }    
                Else    
                {    
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 2 0 "HALB"                                           WriteWordLine 4 0 "General"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 1 "HALB"                                           Line 3 "General"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                WriteHTMLLine 2 0 "HALB"                                           #Nothing
                        }                                   }
     
                        Write-Verbose "$(Get-Date -Format G): `t`tOutput HALB"    
                        ForEach($HALB in $HALBs)    
                        {    
                                $HALBStatusResult = Get-RASHALBStatus -Name $HALB.Name -EA 0 4> $Null     
 
                                If($? -and $Null -ne $HALBStatusResult) <>                                 Switch ($VDITemplate.UnusedVMDurationMins)
 
                                        $HALBStatus = GetRASStatus $HALBStatusResult.AgentState <>                                         0               {$DeleteVMTime = "Never"; Break}
                                            5               {$DeleteVMTime = "5 minutes"; Break}
                                            30              {$DeleteVMTime = "30 minutes"; Break}
                                            60              {$DeleteVMTime = "1 hour"; Break}
                                            1440    {$DeleteVMTime = "1 day"; Break}
                                            10080   {$DeleteVMTime = "1 week"; Break}
                                            43200   {$DeleteVMTime = "30 days"; Break}
                                            Default {$DeleteVMTime = "Unable to determine Delete unused VMs after: $($VDITemplate.UnusedVMDurationMins)"; Break}
 
                                Else <>                                
                                    Switch($VDITemplate.CloneMethod)
 
                                        $HALBStatus = "Unable to determine HALB status" <>                                         "LinkedClone"   {$CloneMethod = "Create a linked clone"; Break}
                                            "FullClone"             {$CloneMethod = "Create a full clone"; Break}
                                            Default                 {$CloneMethod = "Unable to determine Clone method: $($VDITemplate.CloneMethod)"; Break}
 
                                 <>  
 
                                        WriteWordLine 3 0 "HALB $($HALB.Name)" +-  
 
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Template name"; Value = $VDITemplate.Name; }) > $Null
                                        $ScriptInformation.Add(@{Data = "IPv4"; Value = $HALB.VirtualIPV4; }) > $Null                                           $ScriptInformation.Add(@{Data = "Maximum guest VMs"; Value = $VDITemplate.MaxVMs.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "IPv6"; Value = $HALB.VirtualIPV6; }) > $Null                                           $ScriptInformation.Add(@{Data = "Keep available buffer"; Value = $VDITemplate.PreCreatedVMs.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Status"; Value = $HALBStatus; }) > $Null                                           $ScriptInformation.Add(@{Data = "Guest VM name"; Value = $VDITemplate.VMNameFormat; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Guest VM state after the preparation"; Value = "Can't find"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Public Address"; Value = $HALB.PublicAddress; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Last modification by"; Value = $HALB.AdminLastMod; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Modified on"; Value = $HALB.TimeLastMod.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Delete unused guest VMs after"; Value = $DeleteVMTime; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created by"; Value = $HALB.AdminCreate; }) > $Null                                           $ScriptInformation.Add(@{Data = "Clone method"; Value = $CloneMethod; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Created on"; Value = $HALB.TimeCreate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "ID"; Value = $HALB.Id.ToString(); }) > $Null    
 
                                        Line 2 "HALB $($HALB.Name)" <>  
                                        Line 3 "Name`t`t`t: " $HALB.Name                                           Line 4 "Template name`t`t`t: " $VDITemplate.Name
                                        Line 3 "IPv4`t`t`t: " $HALB.VirtualIPV4    
                                        Line 3 "IPv6`t`t`t: " $HALB.VirtualIPV6    
                                        Line 3 "Status`t`t`t: " $HALBStatus    
                                        Line 3 "Description`t`t: " $HALB.Description    
                                        Line 3 "Public Address`t`t: " $HALB.PublicAddress    
                                        Line 3 "Last modification by`t: " $HALB.AdminLastMod    
                                        Line 3 "Modified on`t`t: " $HALB.TimeLastMod.ToString()                                           Line 4 "Maximum guest VMs`t`t: " $VDITemplate.MaxVMs.ToString()
                                        Line 3 "Created by`t`t: " $HALB.AdminCreate    
                                        Line 3 "Created on`t`t: " $HALB.TimeCreate.ToString()                                           Line 4 "Keep available buffer`t`t: " $VDITemplate.PreCreatedVMs.ToString()
                                        Line 3 "ID`t`t`t: " $HALB.Id.ToString()                                           Line 4 "Guest VM state after the preparation`t: " "Can't find"
                                            Line 4 "Guest VM name`t`t`t: " $VDITemplate.VMNameFormat
                                            Line 4 "Delete unused guest VMs after`t: " $DeleteVMTime
                                            Line 4 "Clone method`t`t`t: " $CloneMethod
 
                                        WriteHTMLLine 3 0 "HALB $($HALB.Name)" +-  
 
                                        $columnHeaders = @("Name",($Script:htmlsb),$HALB.Name,$htmlwhite) <>                                         $columnHeaders = @("Template name",($Script:htmlsb),$VDITemplate.Name,$htmlwhite)
                                        $rowdata += @(,("IPv4",($Script:htmlsb),$HALB.VirtualIPV4,$htmlwhite))                                           $rowdata += @(,("Maximum guest VMs",($Script:htmlsb),$VDITemplate.MaxVMs.ToString(),$htmlwhite))
                                        $rowdata += @(,("IPv6",($Script:htmlsb),$HALB.VirtualIPV6,$htmlwhite))                                           $rowdata += @(,("Keep available buffer",($Script:htmlsb),$VDITemplate.PreCreatedVMs.ToString(),$htmlwhite))
                                        $rowdata += @(,("Status",($Script:htmlsb),$HALBStatus,$htmlwhite))                                           $rowdata += @(,("Guest VM name",($Script:htmlsb),$VDITemplate.VMNameFormat,$htmlwhite))
                                        $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))                                           $rowdata += @(,("Guest VM state after the preparation",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("Public Address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))    
                                        $rowdata += @(,("Last modification by",($Script:htmlsb), $HALB.AdminLastMod,$htmlwhite))    
                                        $rowdata += @(,("Modified on",($Script:htmlsb), $HALB.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("Delete unused guest VMs after",($Script:htmlsb),$DeleteVMTime,$htmlwhite))
                                        $rowdata += @(,("Created by",($Script:htmlsb), $HALB.AdminCreate,$htmlwhite))                                           $rowdata += @(,("Clone method",($Script:htmlsb),$CloneMethod,$htmlwhite))
                                        $rowdata += @(,("Created on",($Script:htmlsb), $HALB.TimeCreate.ToString(),$htmlwhite))    
                                        $rowdata += @(,("ID",($Script:htmlsb),$HALB.Id.ToString(),$htmlwhite))    
 
                                        $msg = "" <>                                         $msg = "Properties"
 
  <>                                 
                                    #Advanced
                                    
 
                                        WriteWordLine 4 0 "General" <>                                         WriteWordLine 4 0 "Advanced"
 
                                        Line 2 "General" <>                                         Line 3 "Advanced"
 
                                Switch($HALB.IPVersion) +-  
                                {    
                                        "Version4"              {$HALBIPVersion = "Version 4"; Break}    
                                        "Version6"              {$HALBIPVersion = "Version 6"; Break}    
                                        "BothVersions"  {$HALBIPVersion = "Both version 4 & 6"; Break}    
                                        Default                 {$HALBIPVersion = "Unable to determine IP version: $($HALB.IPVersion)"; Break}    
                                }    
                                    
 
                                        $ScriptInformation.Add(@{Data = "Enable HALB"; Value = $HALB.EnableHALBInstance.ToString(); }) > $Null <>                                         $ScriptInformation.Add(@{Data = "Folder"; Value = $VDITemplate.FolderName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null                                           $ScriptInformation.Add(@{Data = "Resource pool"; Value = $VDITemplate.NativePoolName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Physical Host"; Value = $VDITemplate.PhysicalHostName; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Public address"; Value = $HALB.PublicAddress; }) > $Null                                           $ScriptInformation.Add(@{Data = "Enable hardware acceleration graphics licensing support"; Value = $VDITemplate.HWGPU.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "Virtual IP"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $HALBIPVersion; }) > $Null                                           #$ScriptInformation.Add(@{Data = "Use a separate network interface for LAN access"; Value = "Can't find"; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     IPv4"; Value = $HALB.VirtualIPV4; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Subnet Mask"; Value = $HALB.SubNetMask; }) > $Null                                           #$ScriptInformation.Add(@{Data = "Specify management network details"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     IPv6"; Value = $HALB.VirtualIPV6; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Prefix"; Value = $HALB.PrefixIPV6; }) > $Null                                           #$ScriptInformation.Add(@{Data = "     Address"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null                                           #$ScriptInformation.Add(@{Data = "     Subnet mask"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "     LB Gateway Payload"; Value = $HALB.EnableGWPayload.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     LB SSL Payload"; Value = $HALB.EnableSSLPayload.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "     Device Management"; Value = $HALB.EnableDeviceManagement.ToString(); }) > $Null    
 
                                        Line 3 "Enable HALB`t`t`t: " $HALB.EnableHALBInstance.ToString() <>  
                                        Line 3 "Name`t`t`t`t: " $HALB.Name                                           Line 4 "Folder`t`t`t`t: " $VDITemplate.FolderName
                                            Line 4 "Resource pool`t`t`t: " $VDITemplate.NativePoolName
                                            Line 4 "Physical Host`t`t`t: " $VDITemplate.PhysicalHostName
                                            Line 4 "Enable hardware acceleration "
                                        Line 3 "Description`t`t`t: " $HALB.Description                                           Line 4 "graphics licensing support`t: " $VDITemplate.HWGPU.ToString()
                                            #Line 4 "Use a separate network interface for LAN access: " "Can't find"
                                            #Line 4 "Specify management network details:"
                                        Line 3 "Public address`t`t`t: " $HALB.PublicAddress                                           #Line 5 "Address`t`t`t: " $DeleteVMTime
                                        Line 3 "Virtual IP"    
                                        Line 4 "Use IP version`t`t: " $HALBIPVersion    
                                        Line 4 "IPv4`t`t`t: " $HALB.VirtualIPV4    
                                        Line 4 "Subnet Mask`t`t: " $HALB.SubNetMask                                           #Line 6 "Subnet mask`t`t: " $CloneMethod
                                        Line 4 "IPv6`t`t`t: " $HALB.VirtualIPV6    
                                        Line 4 "Prefix`t`t`t: " $HALB.PrefixIPV6    
                                        Line 3 "Settings"    
                                        Line 4 "LB Gateway Payload`t: " $HALB.EnableGWPayload.ToString()    
                                        Line 4 "LB SSL Payload`t`t: " $HALB.EnableSSLPayload.ToString()    
                                        Line 4 "Device Management`t: " $HALB.EnableDeviceManagement.ToString()    
 
                                        $columnHeaders = @("Enable HALB",($Script:htmlsb),$HALB.EnableHALBInstance.ToString(),$htmlwhite) <>                                         $columnHeaders = @("Folder",($Script:htmlsb),$VDITemplate.FolderName,$htmlwhite)
                                        $rowdata += @(,("Name",($Script:htmlsb),$HALB.Name,$htmlwhite))                                           $rowdata += @(,("Resource pool",($Script:htmlsb),$VDITemplate.NativePoolName,$htmlwhite))
                                        $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))                                           $rowdata += @(,("Physical Host",($Script:htmlsb),$VDITemplate.PhysicalHostName,$htmlwhite))
                                        $rowdata += @(,("Public address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))                                           $rowdata += @(,("Enable hardware acceleration graphics licensing support",($Script:htmlsb),$VDITemplate.HWGPU.ToString(),$htmlwhite))
                                        $rowdata += @(,("Virtual IP",($Script:htmlsb), "",$htmlwhite))    
                                        $rowdata += @(,("     Use IP version",($Script:htmlsb), $HALBIPVersion,$htmlwhite))                                           #$rowdata += @(,("Use a separate network interface for LAN access",($Script:htmlsb),"Can't find",$htmlwhite))
                                        $rowdata += @(,("     IPv4",($Script:htmlsb), $HALB.VirtualIPV4,$htmlwhite))    
                                        $rowdata += @(,("     Subnet Mask",($Script:htmlsb), $HALB.SubNetMask,$htmlwhite))                                           #$rowdata += @(,("Specify management network details",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("     IPv6",($Script:htmlsb), $HALB.VirtualIPV6,$htmlwhite))    
                                        $rowdata += @(,("     Prefix",($Script:htmlsb), $HALB.PrefixIPV6,$htmlwhite))                                           #$rowdata += @(,("     Address",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("Settings",($Script:htmlsb), "",$htmlwhite))                                           #$rowdata += @(,("     Subnet mask",($Script:htmlsb),"",$htmlwhite))
                                        $rowdata += @(,("     LB Gateway Payload",($Script:htmlsb), $HALB.EnableGWPayload.ToString(),$htmlwhite))    
                                        $rowdata += @(,("     LB SSL Payload",($Script:htmlsb), $HALB.EnableSSLPayload.ToString(),$htmlwhite))    
                                        $rowdata += @(,("     Device Management",($Script:htmlsb), $HALB.EnableDeviceManagement.ToString(),$htmlwhite))    
 
                                        $msg = "General" <>                                         $msg = "Advanced"
                                        $columnWidths = @("200","400")                                           $columnWidths = @("200","275")
 
  <>                                 
                                    #Preparation
                                    
 
                                        WriteWordLine 4 0 "LB gateway payload" <>                                         WriteWordLine 4 0 "Preparation"
 
                                        Line 2 "LB gateway payload" <>                                         Line 3 "Preparation"
 
                                        WriteHTMLLine 4 0 "LB gateway payload" <>                                         #Nothing
 
                                $HALBGatewayPort = $HALB.GatewayConfig.Port.ToString() +-  
                                $HALBGateways    = $HALB.GatewayConfig.Gateways    
                                    
                                #First, get the port    
 
  <>                                         $ScriptInformation.Add(@{Data = "Image preparation tool"; Value = $VDITemplate.ImagePrepTool.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Computer name"; Value = $VDITemplate.ComputerName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Owner name"; Value = $VDITemplate.OwnerName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Organization"; Value = $VDITemplate.Organization; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Port"; Value = $HALBGatewayPort; }) > $Null                                           $ScriptInformation.Add(@{Data = "Active Directory domain"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Domain"; Value = $VDITemplate.Domain; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Administrator"; Value = $VDITemplate.Administrator; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Target OU"; Value = $VDITemplate.DomainOrgUnit; }) > $Null
 
  <>                                         Line 4 "Image preparation tool`t: " $VDITemplate.ImagePrepTool.ToString()
                                            Line 4 "Computer name`t`t: " $VDITemplate.ComputerName
                                            Line 4 "Owner name`t`t: " $VDITemplate.OwnerName
                                            Line 4 "Organization`t`t: " $VDITemplate.Organization
                                        Line 3 "Port: " $HALBGatewayPort                                           Line 4 "Active Directory domain"
                                            Line 5 "Domain`t`t: " $VDITemplate.Domain
                                            Line 5 "Administrator`t: " $VDITemplate.Administrator
                                            Line 5 "Target OU`t: " $VDITemplate.DomainOrgUnit
 
  <>                                         $columnHeaders = @("Image preparation tool",($Script:htmlsb),$VDITemplate.ImagePrepTool.ToString(),$htmlwhite)
                                        $columnHeaders = @("Port",($Script:htmlsb),$HALBGatewayPort,$htmlwhite)                                           $rowdata += @(,("Computer name",($Script:htmlsb),$VDITemplate.ComputerName,$htmlwhite))
                                            $rowdata += @(,("Owner name",($Script:htmlsb),$VDITemplate.OwnerName,$htmlwhite))
                                            $rowdata += @(,("Organization",($Script:htmlsb),$VDITemplate.Organization,$htmlwhite))
                                        #$rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Active Directory domain",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("     Domain",($Script:htmlsb),$VDITemplate.Domain,$htmlwhite))
                                            $rowdata += @(,("     Administrator",($Script:htmlsb),$VDITemplate.Administrator,$htmlwhite))
                                            $rowdata += @(,("     Target OU",($Script:htmlsb),$VDITemplate.DomainOrgUnit,$htmlwhite))
 
                                        $msg = "" <>                                         $msg = "Preparation"
                                        $columnWidths = @("200","400")                                           $columnWidths = @("200","275")
 
                                #second, process the gateways <>                                 #User Profile
                                #do output headers                          
 
                                        [System.Collections.Hashtable[]] $GatewaysWordTable = @(); <>                                         WriteWordLine 4 0 "User profile"
 
                                        Line 3 "Gateways                                                 Statu                                 " <>                                         Line 3 "User profile"
                                        Line 3 "================================================================================================="    
                                        #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890    
                                        #       1234567890123456789012345678901234567890123456789012345    
 
                                        $rowdata = @() <>                                         #Nothing
 
                                 <>  
                                #process the gateways data                                   If($VDITemplate.InheritDefaultUserProfileSettings)
                                ForEach($GWItem in $HALBGateways)    
 
                                        $ip = $GWItem.Keys <>                                         #do we inherit site defaults?
                                        $Results = [System.Net.Dns]::gethostentry($ip)                                           #yes we do, get the default settings for the Site
                                        $hostname = $Results.HostName                                           #use the Site default settings
                                            
                                            #Template technology settings do not include UPD, only FSLogix
                                        $TempGW = Get-RASGWStatus -Server $hostname -EA 0 4> $Null                                           $TemplateDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                        $HALBGWStatus = GetRASStatus $TempGW.AgentState    
 
                                        If($MSWord -or $PDF) <>                                         If($? -and $Null -ne $TemplateDefaults)
 
                                                $GatewaysWordTableRowHash = @{ <>  
                                                        Gateway       = "$hostname ($ip)";                                                   Switch ($TemplateDefaults.Technology)
                                                        GatewayStatus = $HALBGWStatus;                                                   {
                                                            "DoNotManage"                           {$TemplateTechnology = "Do not manage by RAS"; Break}
                                                            "FSLogixProfileContainer"       {$TemplateTechnology = "FSLogix"; Break}
                                                            Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($TemplateDefaults.Technology)"; Break}
 
                                                $GatewaysWordTable += $GatewaysWordTableRowHash <>                                                
                                                    $FSLogixSettings           = $TemplateDefaults.FSLogix.ProfileContainer
                                                    $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}
                                                    
                                                    Switch($FSLogixDeploymentSettings.InstallType)
                                                    {
                                                            "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}
                                                            "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}
                                                            "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}
                                                            "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}
                                                            Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}
                                        }                                                   }
                                                    
                                                    $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL
                                                    $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath
                                                    $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName
                                                    $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
     
                                                    Switch ($FSLogixSettings.LocationType)
                                                    {
                                                            "SMBLocation"   
                                                            {
                                                                    $FSLogixLocationType = "SMB Location"
                                                                    $FSLogixLocationOfProfileDisks = $FSLogixSettings.VHDLocations
                                                                    Break
                                                            }
                                                            "CloudCache"    
                                                            {
                                                                    $FSLogixLocationType = "Cloud Cache"
                                                                    $FSLogixLocationOfProfileDisks = $FSLogixSettings.CCDLocations
                                                                    Break
                                                            }
                                        If($Text)                                                           Default                
                                        {                                                           {
                                                Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)                                                                   $FSLogixLocationType = "Unable to determine FSLogix Location type: $($FSLogixSettings.LocationType)"
                                                                    $FSLogixLocationOfProfileDisks = @()
                                                                    Break
                                        }                                                           }
                                        If($HTML)                                                   }
                                                    
                                                    Switch ($FSLogixSettings.ProfileDiskFormat)
                                        {                                                   {
                                                $rowdata += @(,(                                                           "VHD"   {$FSLogixProfileDiskFormat = "VHD"; Break}
                                                "$hostname ($ip)",$htmlwhite,                                                           "VHDX"  {$FSLogixProfileDiskFormat = "VHDX"; Break}
                                                $HALBGWStatus,$htmlwhite))                                                           Default {$FSLogixProfileDiskFormat = "Unable to determine FSLogix Profile disk format: $($FSLogixSettings.ProfileDiskFormat)"; Break}
                                        }                                                   }
                                                    
                                                    Switch ($FSLogixSettings.AllocationType)
                                                    {
                                                            "Dynamic"       {$FSLogixAllocationType = "Dynamic"; Break}
                                                            "Full"          {$FSLogixAllocationType = "Full"; Break}
                                                            Default         {$FSLogixAllocationType = "Unable to determine FSLogix Allocation type: $($FSLogixSettings.AllocationType)"; Break}
                                }                                                   }
                                                                                  
                                #output the Word/PDF and HTML tables                                                   $FSLogixDefaultSize = $FSLogixSettings.DefaultSize.ToString()
                                If($MSWord -or $PDF)                                                          
                                                    #FSLogix Additional settings
                                                    #Users and Groups tab
                                                    If($FSLogixSettings.UserInclusionList.Count -eq 0)
                                {                                                   {
                                        If($GatewaysWordTable.Count -gt 0)                                                           $FSLogixSettingsUserInclusionList = @("Everyone")
                                                    }
                                                    Else
                                        {                                                   {
                                                $Table = AddWordTable -Hashtable $GatewaysWordTable `                                                           $FSLogixSettingsUserInclusionList = $FSLogixSettings.UserInclusionList
                                                -Columns  Gateway,GatewayStatus `                                                   }
                                                -Headers  "Gateways","Status"`                                                   $FSLogixSettingsUserExclusionList       = $FSLogixSettings.UserExclusionList
                                                            
                                                -Format $wdTableGrid `                                                   #Folders tab
                                                -AutoFit $wdAutoFitFixed;                                                   $FSLogixSettingsCustomizeProfileFolders = $FSLogixSettings.CustomizeProfileFolders
                                                    $FSLogixSettingsExcludeCommonFolders    = $FSLogixSettings | Select-Object -ExpandProperty ExcludeCommonFolders
                                                    $ExcludedCommonFolders                  = @()
                                                    $FSLogixSettingsFolderInclusionList     = $FSLogixSettings.FolderInclusionList
                                                    $FSLogixSettingsFolderExclusionList     = $FSLogixSettings.FolderExclusionList
 
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15; <>                                                 If($FSLogixSettingsCustomizeProfileFolders)
                                                    {
                                                $Table.Columns.Item(1).Width = 200;                                                           #####################################################################################
                                                $Table.Columns.Item(2).Width = 250;                                                           #MANY thanks to Guy Leech for helping me figure out how to process and use this Enum#
                                                            #####################################################################################
 
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                                         #this is cumulative
                                                            #Contacts, Desktop, Documents, Links, MusicPodcasts, PicturesVideos, FoldersLowIntegProcesses
                                                            If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Contacts)
                                                            {
                                                                    $ExcludedCommonFolders += "Contacts"
                                                            }
                                                            If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Desktop)
                                                            {
                                                FindWordDocumentEnd                                                                   $ExcludedCommonFolders += "Desktop"
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }                                                           }
                                                            If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Documents)
                                                            {
                                                                    $ExcludedCommonFolders += "Documents"
                                }                                                           }
                                If($Text)                                                           If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Links)
                                {                                                           {
                                                                    $ExcludedCommonFolders += "Links"
                                        Line 0 ""                                                           }
                                                            If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::MusicPodcasts)
                                                            {
                                                                    $ExcludedCommonFolders += 'Music & Podcasts'
                                }                                                           }
                                If($HTML)                                                           If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::PicturesVideos)
                                {                                                           {
                                        $columnHeaders = @(                                                                   $ExcludedCommonFolders += 'Pictures & Videos'
                                        "Gateways",($Script:htmlsb),                                                           }
                                        "Status",($Script:htmlsb))                                                           If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::FoldersLowIntegProcesses)
                                                            {
                                                                    $ExcludedCommonFolders += "Folders used by Low Integrity processes"
                                        $msg = ""                                                           }
                                        $columnWidths = @("200","400")    
                                        FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"    
                                        WriteHTMLLine 0 0 ""    
                                }                                                   }
                                                            
                                                    #Advanced tab
                                                    $FSLogixAS = $FSLogixSettings.AdvancedSettings
                                                                                  
                                If($MSWord -or $PDF)                                                   Switch($FSLogixAS.AccessNetworkAsComputerObject)
                                {                                                   {
                                        WriteWordLine 4 0 "LB SSL payload"                                                           "Enable"        {$FSLogixAS_AccessNetworkAsComputerObject = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_AccessNetworkAsComputerObject = "Disable"; Break}
                                                            Default         {$FSLogixAS_AccessNetworkAsComputerObject = "Unknown: $($FSLogixAS.AccessNetworkAsComputerObject)"; Break}
                                }                                                   }
                                If($Text)                                                  
                                                    $FSLogixAS_AttachVHDSDDL = $FSLogixAS.AttachVHDSDDL
                                                    
                                                    Switch($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)
                                {                                                   {
                                        Line 2 "LB SSL payload"                                                           "Enable"        {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"; Break}
                                                            Default         {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Unknown: $($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)"; Break}
                                }                                                   }
                                If($HTML)    
                                                    $FSLogixAS_DiffDiskParentFolderPath = $FSLogixAS.DiffDiskParentFolderPath  
     
                                                    Switch($FSLogixAS.FlipFlopProfileDirectoryName)
                                {                                                   {
                                        #Nothing                                                           "Enable"        {$FSLogixAS_FlipFlopProfileDirectoryName = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_FlipFlopProfileDirectoryName = "Disable"; Break}
                                                            Default         {$FSLogixAS_FlipFlopProfileDirectoryName = "Unknown: $($FSLogixAS.FlipFlopProfileDirectoryName)"; Break}
                                }                                                   }
                                                                                  
                                                    Switch($FSLogixAS.KeepLocalDir)
                                                    {
                                                            "Enable"        {$FSLogixAS_KeepLocalDir = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_KeepLocalDir = "Disable"; Break}
                                                            Default         {$FSLogixAS_KeepLocalDir = "Unknown: $($FSLogixAS.KeepLocalDir)"; Break}
                                                    }
     
                                $HALBSSLGatewayPort = $HALB.SSLConfig.GatewayConfig.Port.ToString()                                                   $FSLogixAS_LockedRetryCount    = $FSLogixAS.LockedRetryCount                       
                                $HALBSSLGateways    = $HALB.SSLConfig.GatewayConfig.Gateways                                                   $FSLogixAS_LockedRetryInterval = $FSLogixAS.LockedRetryInterval     
                                                                                  
                                                    Switch($FSLogixAS.NoProfileContainingFolder)
                                                    {
                                                            "Enable"        {$FSLogixAS_NoProfileContainingFolder = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_NoProfileContainingFolder = "Disable"; Break}
                                                            Default         {$FSLogixAS_NoProfileContainingFolder = "Unknown: $($FSLogixAS.NoProfileContainingFolder)"; Break}
                                                    }
     
                                Switch($HALB.SSLConfig.SSLMode)                                                   Switch($FSLogixAS.OutlookCachedMode)
                                {                                                   {
                                        "SSLOffloading"         {$HALBSSLMode = "SSL Offloading"; Break}                                                           "Enable"        {$FSLogixAS_OutlookCachedMode = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_OutlookCachedMode = "Disable"; Break}
                                                            Default         {$FSLogixAS_OutlookCachedMode = "Unknown: $($FSLogixAS.OutlookCachedMode)"; Break}
                                                    }
     
                                                    Switch($FSLogixAS.PreventLoginWithFailure)
                                                    {
                                                            "Enable"        {$FSLogixAS_PreventLoginWithFailure = "Enable"; Break}
                                        "SSLPassthrough"        {$HALBSSLMode = "Passthrough"; Break}                                                           "Disable"       {$FSLogixAS_PreventLoginWithFailure = "Disable"; Break}
                                                            Default         {$FSLogixAS_PreventLoginWithFailure = "Unknown: $($FSLogixAS.PreventLoginWithFailure)"; Break}
                                                    }
     
                                                    Switch($FSLogixAS.PreventLoginWithTempProfile)
                                                    {
                                                            "Enable"        {$FSLogixAS_PreventLoginWithTempProfile = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_PreventLoginWithTempProfile = "Disable"; Break}
                                                            Default         {$FSLogixAS_PreventLoginWithTempProfile = "Unknown: $($FSLogixAS.PreventLoginWithTempProfile)"; Break}
                                                    }
     
                                                    $FSLogixAS_ProfileDirSDDL = $FSLogixAS.ProfileDirSDDL
     
                                                    Switch($FSLogixAS.ProfileType)
                                                    {
                                                            "NormalProfile" {$FSLogixAS_ProfileType = "Normal profile"; Break}
                                                            "OnlyRWProfile" {$FSLogixAS_ProfileType = "Only RW profile"; Break}
                                                            "OnlyROProfile" {$FSLogixAS_ProfileType = "Only RO profile"; Break}
                                                            "RWROProfile"   {$FSLogixAS_ProfileType = "RW/RO profile"; Break}
                                                            Default                 {$FSLogixAS_ProfileType = "Unknown: $($FSLogixAS.ProfileType)"; Break}
                                                    }
     
                                                    $FSLogixAS_ReAttachIntervalSeconds = $FSLogixAS.ReAttachIntervalSeconds                
                                                    $FSLogixAS_ReAttachRetryCount      = $FSLogixAS.ReAttachRetryCount                     
     
                                                    Switch($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)
                                                    {
                                                            "Enable"        {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Disable"; Break}
                                                            Default         {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Unknown: $($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)"; Break}
                                                    }
     
                                                    Switch($FSLogixAS.RoamSearch)
                                                    {
                                                            "Enable"        {$FSLogixAS_RoamSearch = "Enable"; Break}
                                                            "Disable"       {$FSLogixAS_RoamSearch = "Disable"; Break}
                                                            Default         {$FSLogixAS_RoamSearch = "Unknown: $($FSLogixAS.RoamSearch)"; Break}
                                                    }
     
                                                    Switch($FSLogixAS.SetTempToLocalPath)
                                                    {
                                                            "TakeNoAction"                                  {$FSLogixAS_SetTempToLocalPath = "Take no action"; Break}
                                                            "RedirectTempAndTmp"                    {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP and TMP"; Break}
                                                            "RedirectINetCache"                             {$FSLogixAS_SetTempToLocalPath = "Redirect INetCache"; Break}
                                                            "RedirectTempTmpAndINetCache"   {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP, TMP, and INetCache"; Break}
                                                            Default                                                 {$FSLogixAS_SetTempToLocalPath = "Unknown: $($FSLogixAS.SetTempToLocalPath)"; Break}
                                                    }
     
                                                    $FSLogixAS_SIDDirNameMatch   = $FSLogixAS.SIDDirNameMatch                        
                                                    $FSLogixAS_SIDDirNamePattern = $FSLogixAS.SIDDirNamePattern                      
                                                    $FSLogixAS_SIDDirSDDL        = $FSLogixAS.SIDDirSDDL
                                                    $FSLogixAS_VHDNameMatch      = $FSLogixAS.VHDNameMatch                           
                                                    $FSLogixAS_VHDNamePattern    = $FSLogixAS.VHDNamePattern                         
     
                                                    Switch($FSLogixAS.VHDXSectorSize)
                                                    {
                                                            0               {$FSLogixAS_VHDXSectorSize = "System default"; Break}
                                                            512             {$FSLogixAS_VHDXSectorSize = "512"; Break}
                                                            4096    {$FSLogixAS_VHDXSectorSize = "4096"; Break}
                                        Default                         {$HALBSSLMode = "Unable to etermine SSL Mode: $($HALB.SSLConfig.SSLMode)"; Break}                                                           Default {$FSLogixAS_VHDXSectorSize = "Unknown: $($FSLogixAS.VHDXSectorSize)"; Break}
                                                    }
     
                                                    $FSLogixAS_VolumeWaitTimeMS = $FSLogixAS.VolumeWaitTimeMS                                                               
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $TemplateTechnology                             = "Do not manage by RAS"
                                                    $FSLogixDeploymentSettingsDeploymentMethod      = "None"
                                                    $FSLogixDeploymentSettingsInstallOnlineURL      = "None"
                                                    $FSLogixDeploymentSettingsNetworkDrivePath      = "None"
                                                    $FSLogixDeploymentSettingsInstallerFileName     = "None"
                                                    $FSLogixDeploymentSettingsReplicate             = $False
                                                    $FSLogixLocationType                            = "None"
                                                    $FSLogixLocationOfProfileDisks                  = @()
                                                    $FSLogixProfileDiskFormat                       = "None"
                                                    $FSLogixAllocationType                          = "None"
                                                    $FSLogixDefaultSize                             = "0"
                                                    $FSLogixSettingsUserInclusionList               = @("Everyone")
                                                    $FSLogixSettingsUserExclusionList               = @()
                                                    $FSLogixSettingsCustomizeProfileFolders         = $False
                                                    $FSLogixSettingsExcludeCommonFolders            = "None"
                                                    $ExcludedCommonFolders                          = @()
                                                    $FSLogixSettingsFolderInclusionList             = @()
                                                    $FSLogixSettingsFolderExclusionList             = @()
                                                    $FSLogixAS_AccessNetworkAsComputerObject        = "Disable"
                                                    $FSLogixAS_AttachVHDSDDL                        = "None"
                                                    $FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"
                                                    $FSLogixAS_DiffDiskParentFolderPath             = "%TEMP"
                                                    $FSLogixAS_FlipFlopProfileDirectoryName         = "Disable"
                                                    $FSLogixAS_KeepLocalDir                         = "Disable"
                                                    $FSLogixAS_LockedRetryCount                     = 12
                                                    $FSLogixAS_LockedRetryInterval                  = 5
                                                    $FSLogixAS_NoProfileContainingFolder            = "Disable"
                                                    $FSLogixAS_OutlookCachedMode                    = "Disable"
                                                    $FSLogixAS_PreventLoginWithFailure              = "Disable"
                                                    $FSLogixAS_PreventLoginWithTempProfile          = "Disable"
                                                    $FSLogixAS_ProfileDirSDDL                       = "None"
                                                    $FSLogixAS_ProfileType                          = "Normal profile"
                                                    $FSLogixAS_ReAttachIntervalSeconds              = 10
                                                    $FSLogixAS_ReAttachRetryCount                   = 60
                                                    $FSLogixAS_RemoveOrphanedOSTFilesOnLogoff       = "Enable"
                                                    $FSLogixAS_RoamSearch                           = "Disable"
                                                    $FSLogixAS_SetTempToLocalPath                   = "Redirect TEMP, TMP, and INetCache"
                                                    $FSLogixAS_SIDDirNameMatch                      = "%sid%_%username%"
                                                    $FSLogixAS_SIDDirNamePattern                    = "%sid%_%username%"
                                                    $FSLogixAS_SIDDirSDDL                           = "None"
                                                    $FSLogixAS_VHDNameMatch                         = "Profile*"
                                                    $FSLogixAS_VHDNamePattern                       = "Profile_%username%"
                                                    $FSLogixAS_VHDXSectorSize                       = "System default"
                                                    $FSLogixAS_VolumeWaitTimeMS                     = 20000
                                            }
 
  <>                                 Else
                                    {
                                            #we don't inherit
                                            #get the settings for the template
     
                                            Switch ($VDITemplate.Technology)
                                            {
                                                    "DoNotManage"                           {$TemplateTechnology = "Do not manage by RAS"; Break}
                                                    "FSLogixProfileContainer"       {$TemplateTechnology = "FSLogix"; Break}
                                                    Default                                         {$TemplateTechnology = "Unable to determine Technology State: $($VDITemplate.Technology)"; Break}
                                            }
                                                            
                                            $FSLogixSettings           = $VDITemplate.FSLogix.ProfileContainer
                                            $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}
                                                                          
                                If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                           Switch($FSLogixDeploymentSettings.InstallType)
                                {                                           {
                                                    "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}
                                                    "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}
                                                    "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}
                                                    "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}
                                                    Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}
                                            }
                                            
                                            $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL
                                            $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath
                                            $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName
                                            $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
                                            
                                        Switch($HALB.SSLConfig.MinSSLVersion)                                           Switch ($FSLogixSettings.LocationType)
 
                                                "SSLv2"         {$HALBSSLAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break} <>                                                 "SMBLocation"  
                                                "SSLv3"         {$HALBSSLAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}                                                   {
                                                "TLSv1"         {$HALBSSLAcceptedSSLVersions = "TLS v1.0 - TLS v1.2"; Break}                                                           $FSLogixLocationType = "SMB Location"
                                                "TLSv1_1"       {$HALBSSLAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}                                                           $FSLogixLocationOfProfileDisks = $FSLogixSettings.VHDLocations
                                                "TLSv1_2"       {$HALBSSLAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}                                                           Break
                                                    }
                                                    "CloudCache"    
                                                    {
                                                            $FSLogixLocationType = "Cloud Cache"
                                                            $FSLogixLocationOfProfileDisks = $FSLogixSettings.CCDLocations
                                                            Break
                                                    }
                                                    Default                 
                                                    {
                                                            $FSLogixLocationType = "Unable to determine FSLogix Location type: $($FSLogixSettings.LocationType)"
                                                            $FSLogixLocationOfProfileDisks = @()
                                                            Break
                                                    }
                                            }
                                            
                                            Switch ($FSLogixSettings.ProfileDiskFormat)
                                            {
                                                    "VHD"   {$FSLogixProfileDiskFormat = "VHD"; Break}
                                                    "VHDX"  {$FSLogixProfileDiskFormat = "VHDX"; Break}
                                                    Default {$FSLogixProfileDiskFormat = "Unable to determine FSLogix Profile disk format: $($FSLogixSettings.ProfileDiskFormat)"; Break}
                                            }
                                            
                                            Switch ($FSLogixSettings.AllocationType)
                                            {
                                                    "Dynamic"       {$FSLogixAllocationType = "Dynamic"; Break}
                                                    "Full"          {$FSLogixAllocationType = "Full"; Break}
                                                Default         {$HALBSSLAcceptedSSLVersions = "Unable to determine Minimum SSL version: $($HALB.SSLConfig.MinSSLVersion)"; Break}                                                   Default         {$FSLogixAllocationType = "Unable to determine FSLogix Allocation type: $($FSLogixSettings.AllocationType)"; Break}
 
  <>                                         $FSLogixDefaultSize = $FSLogixSettings.DefaultSize.ToString()
                                                            
                                            #FSLogix Additional settings
                                            #Users and Groups tab
                                        If($HALB.SSLConfig.SSLCipherStrength -eq "Custom")                                           If($FSLogixSettings.UserInclusionList.Count -eq 0)
 
                                                $HALBSSLCipherStrength = "Custom" <>                                                 $FSLogixSettingsUserInclusionList = @("Everyone")
                                                $HALBSSLCipher         = $HALB.SSLConfig.SSLCustomCipher    
 
                                                $HALBSSLCipherStrength = $HALB.SSLConfig.SSLCipherStrength <>                                                 $FSLogixSettingsUserInclusionList = $FSLogixSettings.UserInclusionList
                                            }
                                            $FSLogixSettingsUserExclusionList       = $FSLogixSettings.UserExclusionList
                                                            
                                            #Folders tab
                                            $FSLogixSettingsCustomizeProfileFolders = $FSLogixSettings.CustomizeProfileFolders
                                            $FSLogixSettingsExcludeCommonFolders    = $FSLogixSettings | Select-Object -ExpandProperty ExcludeCommonFolders
                                            $ExcludedCommonFolders                  = @()
                                            $FSLogixSettingsFolderInclusionList     = $FSLogixSettings.FolderInclusionList
                                            $FSLogixSettingsFolderExclusionList     = $FSLogixSettings.FolderExclusionList
     
                                            If($FSLogixSettingsCustomizeProfileFolders)
                                            {
                                                    #####################################################################################
                                                    #MANY thanks to Guy Leech for helping me figure out how to process and use this Enum#
                                                    #####################################################################################
     
                                                    #this is cumulative
                                                    #Contacts, Desktop, Documents, Links, MusicPodcasts, PicturesVideos, FoldersLowIntegProcesses
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Contacts)
                                                    {
                                                            $ExcludedCommonFolders += "Contacts"
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Desktop)
                                                    {
                                                            $ExcludedCommonFolders += "Desktop"
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Documents)
                                                    {
                                                            $ExcludedCommonFolders += "Documents"
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::Links)
                                                    {
                                                            $ExcludedCommonFolders += "Links"
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::MusicPodcasts)
                                                    {
                                                            $ExcludedCommonFolders += 'Music & Podcasts'
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::PicturesVideos)
                                                    {
                                                            $ExcludedCommonFolders += 'Pictures & Videos'
                                                    }
                                                    If($FSLogixSettingsExcludeCommonFolders -band [RASAdminEngine.Core.OutputModels.UserProfile.FSLogix.ExcludeCommonFolders]::FoldersLowIntegProcesses)
                                                    {
                                                            $ExcludedCommonFolders += "Folders used by Low Integrity processes"
                                                    }
                                            }
                                            
                                            #Advanced tab
                                            $FSLogixAS = $FSLogixSettings.AdvancedSettings
                                            
                                            Switch($FSLogixAS.AccessNetworkAsComputerObject)
                                            {
                                                    "Enable"        {$FSLogixAS_AccessNetworkAsComputerObject = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_AccessNetworkAsComputerObject = "Disable"; Break}
                                                    Default         {$FSLogixAS_AccessNetworkAsComputerObject = "Unknown: $($FSLogixAS.AccessNetworkAsComputerObject)"; Break}
                                            }
                                            
                                            $FSLogixAS_AttachVHDSDDL = $FSLogixAS.AttachVHDSDDL
                                            
                                            Switch($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)
                                            {
                                                    "Enable"        {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Disable"; Break}
                                                    Default         {$FSLogixAS_DeleteLocalProfileWhenVHDShouldApply = "Unknown: $($FSLogixAS.DeleteLocalProfileWhenVHDShouldApply)"; Break}
                                            }
     
                                            $FSLogixAS_DiffDiskParentFolderPath = $FSLogixAS.DiffDiskParentFolderPath  
     
                                            Switch($FSLogixAS.FlipFlopProfileDirectoryName)
                                            {
                                                    "Enable"        {$FSLogixAS_FlipFlopProfileDirectoryName = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_FlipFlopProfileDirectoryName = "Disable"; Break}
                                                    Default         {$FSLogixAS_FlipFlopProfileDirectoryName = "Unknown: $($FSLogixAS.FlipFlopProfileDirectoryName)"; Break}
                                            }
                                            
                                            Switch($FSLogixAS.KeepLocalDir)
                                            {
                                                    "Enable"        {$FSLogixAS_KeepLocalDir = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_KeepLocalDir = "Disable"; Break}
                                                    Default         {$FSLogixAS_KeepLocalDir = "Unknown: $($FSLogixAS.KeepLocalDir)"; Break}
                                            }
     
                                            $FSLogixAS_LockedRetryCount    = $FSLogixAS.LockedRetryCount                       
                                            $FSLogixAS_LockedRetryInterval = $FSLogixAS.LockedRetryInterval     
                                            
                                            Switch($FSLogixAS.NoProfileContainingFolder)
                                            {
                                                    "Enable"        {$FSLogixAS_NoProfileContainingFolder = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_NoProfileContainingFolder = "Disable"; Break}
                                                    Default         {$FSLogixAS_NoProfileContainingFolder = "Unknown: $($FSLogixAS.NoProfileContainingFolder)"; Break}
                                            }
     
                                            Switch($FSLogixAS.OutlookCachedMode)
                                            {
                                                    "Enable"        {$FSLogixAS_OutlookCachedMode = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_OutlookCachedMode = "Disable"; Break}
                                                    Default         {$FSLogixAS_OutlookCachedMode = "Unknown: $($FSLogixAS.OutlookCachedMode)"; Break}
                                            }
     
                                            Switch($FSLogixAS.PreventLoginWithFailure)
                                            {
                                                    "Enable"        {$FSLogixAS_PreventLoginWithFailure = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_PreventLoginWithFailure = "Disable"; Break}
                                                    Default         {$FSLogixAS_PreventLoginWithFailure = "Unknown: $($FSLogixAS.PreventLoginWithFailure)"; Break}
                                            }
     
                                                Switch($HALB.SSLConfig.SSLCipherStrength)                                           Switch($FSLogixAS.PreventLoginWithTempProfile)
                                                {                                           {
                                                        "Low"           {$HALBSSLCipher = "All:!aNULL:!eNULL"; Break}                                                   "Enable"        {$FSLogixAS_PreventLoginWithTempProfile = "Enable"; Break}
                                                        "Medium"        {$HALBSSLCipher = "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"; Break}                                                   "Disable"       {$FSLogixAS_PreventLoginWithTempProfile = "Disable"; Break}
                                                        "High"          {$HALBSSLCipher = "EECDH:!SSLv2:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"; Break}    
                                                        Default         {$HALBSSLCipher = "Unable to determine SSL cipher strength: $($HALB.SSLConfig.SSLCipherStrength)"; Break}                                                   Default         {$FSLogixAS_PreventLoginWithTempProfile = "Unknown: $($FSLogixAS.PreventLoginWithTempProfile)"; Break}
                                                }                                           }
     
                                            $FSLogixAS_ProfileDirSDDL = $FSLogixAS.ProfileDirSDDL
     
                                            Switch($FSLogixAS.ProfileType)
                                            {
                                                    "NormalProfile" {$FSLogixAS_ProfileType = "Normal profile"; Break}
                                                    "OnlyRWProfile" {$FSLogixAS_ProfileType = "Only RW profile"; Break}
                                                    "OnlyROProfile" {$FSLogixAS_ProfileType = "Only RO profile"; Break}
                                                    "RWROProfile"   {$FSLogixAS_ProfileType = "RW/RO profile"; Break}
                                                    Default         {$FSLogixAS_ProfileType = "Unknown: $($FSLogixAS.ProfileType)"; Break}
 
                                        $HALBSSLUseServerPreference = $HALB.SSLConfig.SSLCipherPreference.ToString() <>  
                                        If($HALB.SSLConfig.CertID -eq 0)                                           $FSLogixAS_ReAttachIntervalSeconds = $FSLogixAS.ReAttachIntervalSeconds               
                                            $FSLogixAS_ReAttachRetryCount      = $FSLogixAS.ReAttachRetryCount                     
     
                                            Switch($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)
 
  <>                                                 "Enable"        {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Disable"; Break}
                                                    Default         {$FSLogixAS_RemoveOrphanedOSTFilesOnLogoff = "Unknown: $($FSLogixAS.RemoveOrphanedOSTFilesOnLogoff)"; Break}
                                            }
     
                                            Switch($FSLogixAS.RoamSearch)
                                            {
                                                    "Enable"        {$FSLogixAS_RoamSearch = "Enable"; Break}
                                                    "Disable"       {$FSLogixAS_RoamSearch = "Disable"; Break}
                                                    Default         {$FSLogixAS_RoamSearch = "Unknown: $($FSLogixAS.RoamSearch)"; Break}
                                            }
     
                                            Switch($FSLogixAS.SetTempToLocalPath)
                                            {
                                                    "TakeNoAction"                                  {$FSLogixAS_SetTempToLocalPath = "Take no action"; Break}
                                                    "RedirectTempAndTmp"                    {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP and TMP"; Break}
                                                    "RedirectINetCache"                             {$FSLogixAS_SetTempToLocalPath = "Redirect INetCache"; Break}
                                                    "RedirectTempTmpAndINetCache"   {$FSLogixAS_SetTempToLocalPath = "Redirect TEMP, TMP, and INetCache"; Break}
                                                    Default                                                 {$FSLogixAS_SetTempToLocalPath = "Unknown: $($FSLogixAS.SetTempToLocalPath)"; Break}
                                            }
     
                                            $FSLogixAS_SIDDirNameMatch   = $FSLogixAS.SIDDirNameMatch                        
                                            $FSLogixAS_SIDDirNamePattern = $FSLogixAS.SIDDirNamePattern                      
                                            $FSLogixAS_SIDDirSDDL        = $FSLogixAS.SIDDirSDDL
                                            $FSLogixAS_VHDNameMatch      = $FSLogixAS.VHDNameMatch                           
                                            $FSLogixAS_VHDNamePattern    = $FSLogixAS.VHDNamePattern                         
     
                                            Switch($FSLogixAS.VHDXSectorSize)
                                            {
                                                $HALBSSLCertificates = "All matching usage"                                                   0               {$FSLogixAS_VHDXSectorSize = "System default"; Break}
                                                    512             {$FSLogixAS_VHDXSectorSize = "512"; Break}
                                                    4096    {$FSLogixAS_VHDXSectorSize = "4096"; Break}
                                                    Default {$FSLogixAS_VHDXSectorSize = "Unknown: $($FSLogixAS.VHDXSectorSize)"; Break}
 
  <>  
                                            $FSLogixAS_VolumeWaitTimeMS = $FSLogixAS.VolumeWaitTimeMS                                                               
                                    }
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Technology"; Value = $TemplateTechnology; }) > $Null
     
                                            If($TemplateTechnology -eq "Do not manage by RAS")
                                            {
                                                    #do nothing
                                            }
                                            ElseIf($TemplateTechnology -eq "FSLogix")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null
                                                    If($FSLogixDeploymentSettings.InstallType -eq "Online")
                                                    {
                                                            $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null
                                                    }
                                                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Location type"; Value = $FSLogixLocationType; }) > $Null
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $FSLogixLocationOfProfileDisks)
                                                    {
                                                            $cnt++
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "     Location of profile disks"; Value = $item; }) > $Null
                                                            }
                                        Else                                                           Else
                                        {                                                           {
                                                $Results = Get-RASCertificate -Id $HALB.SSLConfig.CertID -EA 0 4> $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                            }
                                                    }
                                                    $ScriptInformation.Add(@{Data = "     Profile disk format"; Value = $FSLogixProfileDiskFormat; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Allocation type"; Value = $FSLogixAllocationType; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Default size"; Value = "$FSLogixDefaultSize GB"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Additional settings"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Users and Groups"; Value = ""; }) > $Null
 
                                                If($? -and $Null -ne $Results) <>                                                 If($FSLogixSettingsUserInclusionList.Count -eq 0)
 
                                                        $HALBSSLCertificates = $Results.Name <>                                                         $ScriptInformation.Add(@{Data = "          User Inclusion List"; Value = "None"; }) > $Null
 
  <>                                                         $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                        $HALBSSLCertificates = "Unable to find certificate with an ID of $($HALB.SSLConfig.CertID)"                                                                           $ScriptInformation.Add(@{Data = "          User Inclusion List"; Value = "User: $($item.Account)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "User: $($item.Account)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                                    }
                                                            }
 
  <>  
                                                    If($FSLogixSettingsUserExclusionList.Count -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = ""; }) > $Null
                                        }                                                   }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            #$ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = "User: $($item.Account)  Type: $($item.Type)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = "          User Exclusion List"; Value = "User: $($item.Account)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                }                                                                   }
                                Else                                                                   Else
                                {                                                                   {
                                        $HALBSSLAcceptedSSLVersions = ""                                                                           $ScriptInformation.Add(@{Data = ""; Value = "User: $($item.Account)"; }) > $Null
                                        $HALBSSLCipherStrength      = ""                                                                           $ScriptInformation.Add(@{Data = ""; Value = "Type: $($item.Type)"; }) > $Null
                                        $HALBSSLCipher              = ""                                                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                        $HALBSSLUseServerPreference = ""                                                                   }
                                        $HALBSSLCertificates        = ""                                                           }
                                }                                                   }
                                                    $ScriptInformation.Add(@{Data = "     Folders"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Customize profile folders"; Value = $FSLogixSettingsCustomizeProfileFolders.ToString(); }) > $Null
                                                    If($FSLogixSettingsCustomizeProfileFolders)
                                                    {
                                                            If($ExcludedCommonFolders.Count -gt 0)
                                                            {
                                                                    $cnt = -1
                                                                    ForEach($item in $ExcludedCommonFolders)
                                                                    {
                                                                            $cnt++
                                                                                                          
                                #First, get the port                                                                           If($cnt -eq 0)
                                If($MSWord -or $PDF)                                                                           {
                                                                                    $ScriptInformation.Add(@{Data = "               Exclude Common Folders"; Value = $item; }) > $Null
                                                                            }
                                                                            Else
                                {                                                                           {
                                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                            }
                                                                    }
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = "               Exclude Common Folders"; Value = "None"; }) > $Null
                                                            }
                                                    }
     
                                        $ScriptInformation = New-Object System.Collections.ArrayList                                                   If($FSLogixSettingsFolderInclusionList.Count -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "          Folder Inclusion List"; Value = "None"; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = "          Folder Inclusion List"; Value = ""; }) > $Null
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                        $ScriptInformation.Add(@{Data = "Port"; Value = $HALBSSLGatewayPort; }) > $Null                                                                           $ScriptInformation.Add(@{Data = "               Folder"; Value = "$item"; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                        $ScriptInformation.Add(@{Data = "Mode"; Value = $HALBSSLMode; }) > $Null                                                                           $ScriptInformation.Add(@{Data = ""; Value = "$item"; }) > $Null
                                        If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                                                   }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderExclusionList.Count -eq 0)
                                        {                                                   {
                                                            $ScriptInformation.Add(@{Data = "          Folder Exclusion List"; Value = "None"; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                $ScriptInformation.Add(@{Data = "Security"; Value = ""; }) > $Null                                                           $ScriptInformation.Add(@{Data = "          Folder Exclusion List"; Value = ""; }) > $Null
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    Switch($item.ExcludeFolderCopy)
                                                                    {
                                                                            "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}
                                                                            "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}
                                                                            "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}
                                                                            "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}
                                                                            Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}
                                                                    }
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "               Folder"; Value = "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"; }) > $Null
                                                                    }
                                                            }
                                                    }
                                                    
                                                    $ScriptInformation.Add(@{Data = "     Advanced"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          FSLogix Setting:"; Value = "Value:"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Access network as computer object"; Value = "$($FSLogixAS_AccessNetworkAsComputerObject)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Custom SDDL for profile directory"; Value = "$($FSLogixAS_ProfileDirSDDL)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Delay between locked VHD(X) retries"; Value = "$($FSLogixAS_LockedRetryInterval)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Delete local profile when loading from VHD"; Value = "$($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Diff disk parent folder path"; Value = "$($FSLogixAS_DiffDiskParentFolderPath)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Do not create a folder for new profiles"; Value = "$($FSLogixAS_NoProfileContainingFolder)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Enable Cached mode for Outlook"; Value = "$($FSLogixAS_OutlookCachedMode)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Keep local profiles"; Value = "$($FSLogixAS_KeepLocalDir)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Naming pattern for new VHD(X) files"; Value = "$($FSLogixAS_VHDNamePattern)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Accepted SSL Versions"; Value = $HALBSSLAcceptedSSLVersions; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          Number of locked VHD(X) retries"; Value = "$($FSLogixAS_LockedRetryCount)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Prevent logons with failures"; Value = "$($FSLogixAS_PreventLoginWithFailure)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Prevent logons with temp profiles"; Value = "$($FSLogixAS_PreventLoginWithTempProfile)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Cipher Strength"; Value = $HALBSSLCipherStrength; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          Profile folder naming pattern"; Value = "$($FSLogixAS_SIDDirNameMatch)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Cipher"; Value = $HALBSSLCipher; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          Profile type"; Value = "$($FSLogixAS_ProfileType)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Profile VHD(X) file matching pattern"; Value = "$($FSLogixAS_VHDNameMatch)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Re-attach interval"; Value = "$($FSLogixAS_ReAttachIntervalSeconds)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Re-attach retry limit"; Value = "$($FSLogixAS_ReAttachRetryCount)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Remove duplicate OST files on logoff"; Value = "$($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          SDDL used when attaching the VHD"; Value = "$($FSLogixAS_AttachVHDSDDL)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Search roaming feature mode"; Value = "$($FSLogixAS_RoamSearch)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Swap SID and username in profile directory names"; Value = "$($FSLogixAS_FlipFlopProfileDirectoryName)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Use ciphers according to server preference"; Value = $HALBSSLUseServerPreference; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          Temporary folders redirection mode"; Value = "$($FSLogixAS_SetTempToLocalPath)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Use SDDL on creation of SID containing folder"; Value = "$($FSLogixAS_SIDDirSDDL)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          User-to-Profile matching pattern"; Value = "$($FSLogixAS_SIDDirNamePattern)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = "     Certificates"; Value = $HALBSSLCertificates; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          VHDX sector size"; Value = "$($FSLogixAS_VHDXSectorSize)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "          Volume wait time"; Value = "$($FSLogixAS_VolumeWaitTimeMS)"; }) > $Null
 
                                        $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 250;
 
                                        Line 3 "Port: " $HALBSSLGatewayPort <>                                         Line 3 "Inherit default settings`t`t`t`t: " $VDITemplate.InheritDefaultUserProfileSettings.ToString()
                                        Line 3 "Mode: " $HALBSSLMode                                           Line 3 "Technology`t`t`t`t`t`t: " $TemplateTechnology
                                        If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")    
                                            If($TemplateTechnology -eq "Do not manage by RAS")
 
  <>                                                 #do nothing
                                            }
                                            ElseIf($TemplateTechnology -eq "FSLogix")
                                            {
                                                    Line 3 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod
                                                    If($FSLogixDeploymentSettings.InstallType -eq "Online")
                                                    {
                                                            Line 3 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                                                    {
                                                            Line 10 ": " $FSLogixDeploymentSettingsNetworkDrivePath
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                                                    {
                                                            Line 10 ": " $FSLogixDeploymentSettingsInstallerFileName
                                                    }
                                                    Line 3 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()
                                                Line 3 "Security"                                                   Line 3 "Settings"
                                                Line 4 "Accepted SSL Versions`t`t`t`t: " $HALBSSLAcceptedSSLVersions    
                                                Line 4 "Cipher Strength`t`t`t`t`t: " $HALBSSLCipherStrength                                                   Line 4 "Location type`t`t`t`t`t: " $FSLogixLocationType
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $FSLogixLocationOfProfileDisks)
                                                    {
                                                            $cnt++
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    Line 4 "Location of profile disks`t`t`t: " $item
                                                            }
                                                            Else
                                                            {
                                                                    Line 10 "  " $item
                                                            }
                                                    }
                                                    Line 4 "Profile disk format`t`t`t`t: " $FSLogixProfileDiskFormat
                                                Line 4 "Cipher`t`t`t`t`t`t: " $HALBSSLCipher                                                   Line 4 "Allocation type`t`t`t`t`t: " $FSLogixAllocationType
                                                Line 4 "Use ciphers according to server preference`t: " $HALBSSLUseServerPreference    
                                                Line 4 "Certificates`t`t`t`t`t: " $HALBSSLCertificates                                                   Line 4 "Default size`t`t`t`t`t: " "$FSLogixDefaultSize GB"
                                                    Line 3 "Additional settings"
                                                    Line 4 "Users and Groups"
                                                    
                                                    If($FSLogixSettingsUserInclusionList.Count -eq 0)
                                                    {
                                                            Line 5 "User Inclusion List`t`t`t: " "None"
                                                    }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            Line 5 "User Inclusion List`t`t`t: " "User: $($item.Account)  Type: $($item.Type)"
                                                                    }
                                                                    Else
                                                                    {
                                                                            Line 10 "  " "User: $($item.Account)  Type: $($item.Type)"
                                                                    }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsUserExclusionList.Count -eq 0)
                                                    {
                                                            Line 5 "User Exclusion List`t`t`t: " "None"
                                                    }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            Line 5 "User Exclusion List`t`t`t: " "User: $($item.Account)  Type: $($item.Type)"
                                                                    }
                                                                    Else
                                                                    {
                                                                            Line 10 "  " "User: $($item.Account)  Type: $($item.Type)"
                                                                    }
                                                            }
                                                    }
                                                    Line 4 "Folders"
                                                    Line 5 "Customize profile folders`t`t: " $FSLogixSettingsCustomizeProfileFolders.ToString()
                                                    If($FSLogixSettingsCustomizeProfileFolders)
                                                    {
                                                            If($ExcludedCommonFolders.Count -gt 0)
                                                            {
                                                                    $cnt = -1
                                                                    ForEach($item in $ExcludedCommonFolders)
                                                                    {
                                                                            $cnt++
                                                                            
                                                                            If($cnt -eq 0)
                                                                            {
                                                                                    Line 6 "Exclude Common Folders`t`t: " $item
                                                                            }
                                                                            Else
                                                                            {
                                                                                    Line 10 "  " $item
                                                                            }
                                                                    }
                                                            }
                                                            Else
                                                            {
                                                                    Line 6 "Exclude Common Folders`t`t: None"
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderInclusionList.Count -eq 0)
                                                    {
                                                            Line 5 "Folder Inclusion List`t`t`t: " "None"
                                                    }
                                                    Else
                                                    {
                                                            Line 5 "Folder Inclusion List"
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            Line 6 "Folder`t`t`t`t: " $item
                                                                    }
                                                                    Else
                                                                    {
                                                                            Line 10 "  " $item
                                                                    }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderExclusionList.Count -eq 0)
                                                    {
                                                            Line 5 "Folder Exclusion List`t`t`t: " "None"
                                                    }
                                                    Else
                                                    {
                                                            Line 5 "Folder Exclusion List"
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    Switch($item.ExcludeFolderCopy)
                                                                    {
                                                                            "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}
                                                                            "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}
                                                                            "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}
                                                                            "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}
                                                                            Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}
                                                                    }
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            Line 6 "Folder`t`t`t`t: " "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"
                                                                    }
                                                                    Else
                                                                    {
                                                                            Line 10 "  " "$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack"
                                                                    }
                                                            }
                                                    }
                                                    
                                                    Line 4 "Advanced"
                                                    Line 5 "FSLogix Setting                                      Value"
                                                    Line 5 "======================================================================================"
                                                    #      "Swap SID and username in profile directory names     Redirect TEMP, TMP, and INetCache"
                                                    Line 5 "Access network as computer object                    $($FSLogixAS_AccessNetworkAsComputerObject)"
                                                    Line 5 "Custom SDDL for profile directory                    $($FSLogixAS_ProfileDirSDDL)"
                                                    Line 5 "Delay between locked VHD(X) retries                  $($FSLogixAS_LockedRetryInterval)"
                                                    Line 5 "Delete local profile when loading from VHD           $($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)"
                                                    Line 5 "Diff disk parent folder path                         $($FSLogixAS_DiffDiskParentFolderPath)"
                                                    Line 5 "Do not create a folder for new profiles              $($FSLogixAS_NoProfileContainingFolder)"
                                                    Line 5 "Enable Cached mode for Outlook                       $($FSLogixAS_OutlookCachedMode)"
                                                    Line 5 "Keep local profiles                                  $($FSLogixAS_KeepLocalDir)"
                                                    Line 5 "Naming pattern for new VHD(X) files                  $($FSLogixAS_VHDNamePattern)"
                                                    Line 5 "Number of locked VHD(X) retries                      $($FSLogixAS_LockedRetryCount)"
                                                    Line 5 "Prevent logons with failures                         $($FSLogixAS_PreventLoginWithFailure)"
                                                    Line 5 "Prevent logons with temp profiles                    $($FSLogixAS_PreventLoginWithTempProfile)"
                                                    Line 5 "Profile folder naming pattern                        $($FSLogixAS_SIDDirNameMatch)"
                                                    Line 5 "Profile type                                         $($FSLogixAS_ProfileType)"
                                                    Line 5 "Profile VHD(X) file matching pattern                 $($FSLogixAS_VHDNameMatch)"
                                                    Line 5 "Re-attach interval                                   $($FSLogixAS_ReAttachIntervalSeconds)"
                                                    Line 5 "Re-attach retry limit                                $($FSLogixAS_ReAttachRetryCount)"
                                                    Line 5 "Remove duplicate OST files on logoff                 $($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)"
                                                    Line 5 "SDDL used when attaching the VHD                     $($FSLogixAS_AttachVHDSDDL)"
                                                    Line 5 "Search roaming feature mode                          $($FSLogixAS_RoamSearch)"
                                                    Line 5 "Swap SID and username in profile directory names     $($FSLogixAS_FlipFlopProfileDirectoryName)"
                                                    Line 5 "Temporary folders redirection mode                   $($FSLogixAS_SetTempToLocalPath)"
                                                    Line 5 "Use SDDL on creation of SID containing folder        $($FSLogixAS_SIDDirSDDL)"
                                                    Line 5 "User-to-Profile matching pattern                     $($FSLogixAS_SIDDirNamePattern)"
                                                    Line 5 "VHDX sector size                                     $($FSLogixAS_VHDXSectorSize)"
                                                    Line 5 "Volume wait time                                     $($FSLogixAS_VolumeWaitTimeMS)"
 
  -+  
 
  <>                                         $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultUserProfileSettings.ToString(),$htmlwhite)
                                            $rowdata += @(,("Technology",($Script:htmlsb),$TemplateTechnology,$htmlwhite))
     
                                            If($TemplateTechnology -eq "Do not manage by RAS")
                                            {
                                                    #do nothing
                                            }
                                            ElseIf($TemplateTechnology -eq "FSLogix")
                                            {
                                                    $rowdata += @(,("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite))
                                                    If($FSLogixDeploymentSettings.InstallType -eq "Online")
                                                    {
                                                            $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                                                    {
                                        $columnHeaders = @("Port",($Script:htmlsb),$HALBSSLGatewayPort,$htmlwhite)                                                           $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))
                                                    }
                                                    ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))
                                                    }
                                                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))
                                                    $rowdata += @(,("Settings",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("     Location type",($Script:htmlsb),$FSLogixLocationType,$htmlwhite))
                                                    
                                                    $cnt = -1
                                                    ForEach($item in $FSLogixLocationOfProfileDisks)
                                                    {
                                                            $cnt++
                                                            
                                                            If($cnt -eq 0)
                                                            {
                                                                    $rowdata += @(,("     Location of profile disks",($Script:htmlsb),$item,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                        $rowdata += @(,("Mode",($Script:htmlsb),$HALBSSLMode,$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                                        If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")                                                           }
                                                    }
                                                    $rowdata += @(,("     Profile disk format",($Script:htmlsb),$FSLogixProfileDiskFormat,$htmlwhite))
                                                    $rowdata += @(,("     Allocation type",($Script:htmlsb),$FSLogixAllocationType,$htmlwhite))
                                                    $rowdata += @(,("     Default size",($Script:htmlsb),"$FSLogixDefaultSize GB",$htmlwhite))
                                                    $rowdata += @(,("Additional settings",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("     Users and Groups",($Script:htmlsb),"",$htmlwhite))
                                                    
                                                    If($FSLogixSettingsUserInclusionList.Count -eq 0)
                                        {                                                   {
                                                            $rowdata += @(,("          User Inclusion List",($Script:htmlsb),"None",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("          User Inclusion List",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))
                                                $rowdata += @(,( "Security",($Script:htmlsb), "",$htmlwhite))                                                                           $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                                    }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsUserExclusionList.Count -eq 0)
                                                    {
                                                $rowdata += @(,( "     Accepted SSL Versions",($Script:htmlsb), $HALBSSLAcceptedSSLVersions,$htmlwhite))                                                           $rowdata += @(,("          User Exclusion List",($Script:htmlsb),"None",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsUserExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("          User Exclusion List",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"User: $($item.Account)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"Type: $($item.Type)",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                                                    }
                                                            }
                                                    }
                                                    $rowdata += @(,("     Folders",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("          Customize profile folders",($Script:htmlsb),$FSLogixSettingsCustomizeProfileFolders.ToString(),$htmlwhite))
                                                    If($FSLogixSettingsCustomizeProfileFolders)
                                                    {
                                                            If($ExcludedCommonFolders.Count -gt 0)
                                                            {
                                                                    $cnt = -1
                                                                    ForEach($item in $ExcludedCommonFolders)
                                                                    {
                                                                            $cnt++
                                                                            
                                                                            If($cnt -eq 0)
                                                                            {
                                                                                    $rowdata += @(,("               Exclude Common Folders",($Script:htmlsb),$item,$htmlwhite))
                                                                            }
                                                                            Else
                                                                            {
                                                $rowdata += @(,( "     Cipher Strength",($Script:htmlsb), $HALBSSLCipherStrength,$htmlwhite))                                                                                   $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                                                                            }
                                                                    }
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("               Exclude Common Folders",($Script:htmlsb),"None",$htmlwhite))
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderInclusionList.Count -eq 0)
                                                    {
                                                            $rowdata += @(,("          Folder Inclusion List",($Script:htmlsb),"None",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("          Folder Inclusion List",($Script:htmlsb),"",$htmlwhite))
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderInclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("               Folder",($Script:htmlsb),"$item",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                $rowdata += @(,( "     Cipher",($Script:htmlsb), $HALBSSLCipher,$htmlwhite))                                                                           $rowdata += @(,("",($Script:htmlsb),"$item",$htmlwhite))
                                                                    }
                                                            }
                                                    }
     
                                                    If($FSLogixSettingsFolderExclusionList.Count -eq 0)
                                                    {
                                                            $rowdata += @(,("          Folder Exclusion List",($Script:htmlsb),"None",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("          Folder Exclusion List",($Script:htmlsb),"",$htmlwhite))
                                                            $cnt = -1
                                                            ForEach($item in $FSLogixSettingsFolderExclusionList)
                                                            {
                                                                    $cnt++
                                                                    
                                                                    Switch($item.ExcludeFolderCopy)
                                                                    {
                                                                            "None"                                  {$CopyBase = "No "; $CopyBack = "No "; Break}
                                                                            "CopyBack"                              {$CopyBase = "No "; $CopyBack = "Yes"; Break}
                                                                            "CopyBase"                              {$CopyBase = "Yes"; $CopyBack = "No "; Break}
                                                                            "CopyBase, CopyBack"    {$CopyBase = "Yes"; $CopyBack = "Yes"; Break}
                                                                            Default                                 {$CopyBase = "Unknown"; $CopyBack = "Unknown"; Break}
                                                                    }
                                                                    
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("               Folder",($Script:htmlsb),"$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"$($item.Folder) Copy base: $CopyBase Copy back: $CopyBack",$htmlwhite))
                                                                    }
                                                            }
                                                    }
     
                                                    $rowdata += @(,("     Advanced",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("          FSLogix Setting:",($Script:htmlsb),"Value:",$htmlwhite))
                                                    $rowdata += @(,("          Access network as computer object",($Script:htmlsb),"$($FSLogixAS_AccessNetworkAsComputerObject)",$htmlwhite))
                                                    $rowdata += @(,("          Custom SDDL for profile directory",($Script:htmlsb),"$($FSLogixAS_ProfileDirSDDL)",$htmlwhite))
                                                    $rowdata += @(,("          Delay between locked VHD(X) retries",($Script:htmlsb),"$($FSLogixAS_LockedRetryInterval)",$htmlwhite))
                                                    $rowdata += @(,("          Delete local profile when loading from VHD",($Script:htmlsb),"$($FSLogixAS_DeleteLocalProfileWhenVHDShouldApply)",$htmlwhite))
                                                    $rowdata += @(,("          Diff disk parent folder path",($Script:htmlsb),"$($FSLogixAS_DiffDiskParentFolderPath)",$htmlwhite))
                                                    $rowdata += @(,("          Do not create a folder for new profiles",($Script:htmlsb),"$($FSLogixAS_NoProfileContainingFolder)",$htmlwhite))
                                                    $rowdata += @(,("          Enable Cached mode for Outlook",($Script:htmlsb),"$($FSLogixAS_OutlookCachedMode)",$htmlwhite))
                                                    $rowdata += @(,("          Keep local profiles",($Script:htmlsb),"$($FSLogixAS_KeepLocalDir)",$htmlwhite))
                                                    $rowdata += @(,("          Naming pattern for new VHD(X) files",($Script:htmlsb),"$($FSLogixAS_VHDNamePattern)",$htmlwhite))
                                                    $rowdata += @(,("          Number of locked VHD(X) retries",($Script:htmlsb),"$($FSLogixAS_LockedRetryCount)",$htmlwhite))
                                                    $rowdata += @(,("          Prevent logons with failures",($Script:htmlsb),"$($FSLogixAS_PreventLoginWithFailure)",$htmlwhite))
                                                    $rowdata += @(,("          Prevent logons with temp profiles",($Script:htmlsb),"$($FSLogixAS_PreventLoginWithTempProfile)",$htmlwhite))
                                                    $rowdata += @(,("          Profile folder naming pattern",($Script:htmlsb),"$($FSLogixAS_SIDDirNameMatch)",$htmlwhite))
                                                    $rowdata += @(,("          Profile type",($Script:htmlsb),"$($FSLogixAS_ProfileType)",$htmlwhite))
                                                    $rowdata += @(,("          Profile VHD(X) file matching pattern",($Script:htmlsb),"$($FSLogixAS_VHDNameMatch)",$htmlwhite))
                                                    $rowdata += @(,("          Re-attach interval",($Script:htmlsb),"$($FSLogixAS_ReAttachIntervalSeconds)",$htmlwhite))
                                                    $rowdata += @(,("          Re-attach retry limit",($Script:htmlsb),"$($FSLogixAS_ReAttachRetryCount)",$htmlwhite))
                                                    $rowdata += @(,("          Remove duplicate OST files on logoff",($Script:htmlsb),"$($FSLogixAS_RemoveOrphanedOSTFilesOnLogoff)",$htmlwhite))
                                                    $rowdata += @(,("          SDDL used when attaching the VHD",($Script:htmlsb),"$($FSLogixAS_AttachVHDSDDL)",$htmlwhite))
                                                    $rowdata += @(,("          Search roaming feature mode",($Script:htmlsb),"$($FSLogixAS_RoamSearch)",$htmlwhite))
                                                    $rowdata += @(,("          Swap SID and username in profile directory names",($Script:htmlsb),"$($FSLogixAS_FlipFlopProfileDirectoryName)",$htmlwhite))
                                                $rowdata += @(,( "     Use ciphers according to server preference",($Script:htmlsb), $HALBSSLUseServerPreference,$htmlwhite))                                                   $rowdata += @(,("          Temporary folders redirection mode",($Script:htmlsb),"$($FSLogixAS_SetTempToLocalPath)",$htmlwhite))
                                                    $rowdata += @(,("          Use SDDL on creation of SID containing folder",($Script:htmlsb),"$($FSLogixAS_SIDDirSDDL)",$htmlwhite))
                                                    $rowdata += @(,("          User-to-Profile matching pattern",($Script:htmlsb),"$($FSLogixAS_SIDDirNamePattern)",$htmlwhite))
                                                $rowdata += @(,( "     Certificates",($Script:htmlsb), $HALBSSLCertificates,$htmlwhite))                                                   $rowdata += @(,("          VHDX sector size",($Script:htmlsb),"$($FSLogixAS_VHDXSectorSize)",$htmlwhite))
                                                    $rowdata += @(,("          Volume wait time",($Script:htmlsb),"$($FSLogixAS_VolumeWaitTimeMS)",$htmlwhite))
 
                                        $msg = "" <>                                         $msg = "User profile"
                                        $columnWidths = @("200","400")                                           $columnWidths = @("350","325")
 
  -+                                 #>
 
                                #second, process the gateways <>                                 #Optimization
                                #do output headers                                  
 
                                        [System.Collections.Hashtable[]] $GatewaysWordTable = @(); <>                                         WriteWordLine 4 0 "Optimization"
 
                                        Line 3 "Gateways                                                 Status                                  " <>                                         Line 2 "Optimization"
                                        Line 3 "================================================================================================="    
                                        #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890    
                                        #       1234567890123456789012345678901234567890123456789012345    
 
                                        $rowdata = @() <>                                         #Nothing
 
  <>  
                                    If($VDITemplate.InheritDefaultOptimizationSettings)
                                    {
                                            #do we inherit site defaults?
                                            #http://woshub.com/hot-to-convert-sid-to-username-and-vice-versa/
                                            #for translating the User SID to the AD user name
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
                                            $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                                                          
                                #process the gateways data                                           If($? -and $Null -ne $VDIDefaults)
                                ForEach($GWItem in $HALBSSLGateways)                                           {
                                                    $OPTEnableOptimization            = $VDIDefaults.Optimization.EnableOptimization.ToString()
                                                    $OPTOptimizationType              = $VDIDefaults.Optimization.OptimizationType.ToString()
                                                    $OPTWindowsDefenderATPEnabled     = $VDIDefaults.Optimization.WindowsDefenderATPEnabled.ToString()    
                                                    $OPTWindowsComponentsEnabled      = $VDIDefaults.Optimization.WindowsComponentsEnabled.ToString()
                                                    $OPTWindowsServicesEnabled        = $VDIDefaults.Optimization.WindowsServicesEnabled.ToString()
                                                    $OPTWinodwsScheduledTasksEnabled  = $VDIDefaults.Optimization.WindowsScheduledTasksEnabled.ToString()
                                                    $OPTWindowsAdvancedOptionsEnabled = $VDIDefaults.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                                    $OPTNetworkPerformanceEnabled     = $VDIDefaults.Optimization.NetworkPerformanceEnabled.ToString()
                                                    $OPTRegistryEnabled               = $VDIDefaults.Optimization.RegistryEnabled.ToString()
                                                    $OPTVisualEffectsEnabled          = $VDIDefaults.Optimization.VisualEffectsEnabled.ToString()   
                                                    $OPTDiskCleanupEnabled            = $VDIDefaults.Optimization.DiskCleanupEnabled.ToString()
                                                    $OPTCustomScriptEnabled           = $VDIDefaults.Optimization.CustomScriptEnabled.ToString()
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $OPTEnableOptimization            = "False"
                                                    $OPTOptimizationType              = ""
                                                    $OPTWindowsDefenderATPEnabled     = "False"
                                                    $OPTWindowsComponentsEnabled      = "False"
                                                    $OPTWindowsServicesEnabled        = "False"
                                                    $OPTWinodwsScheduledTasksEnabled  = "False"
                                                    $OPTWindowsAdvancedOptionsEnabled = "False"
                                                    $OPTNetworkPerformanceEnabled     = "False"
                                                    $OPTRegistryEnabled               = "False"
                                                    $OPTVisualEffectsEnabled          = "False"
                                                    $OPTDiskCleanupEnabled            = "False"
                                                    $OPTCustomScriptEnabled           = "False"
                                            }
                                    }
                                    Else
 
                                        $ip = $GWItem.Keys <>                                         #we don't inherit
                                        $Results = [System.Net.Dns]::gethostentry($ip)                                           #get the settings for the template
                                        $hostname = $Results.HostName    
                                        $TempGW = Get-RASGWStatus -Server $hostname -EA 0 4> $Null    
                                        $HALBGWStatus = GetRASStatus $TempGW.AgentState    
 
  <>                                         $OPTEnableOptimization            = $VDITemplate.Optimization.EnableOptimization.ToString()
                                            $OPTOptimizationType              = $VDITemplate.Optimization.OptimizationType.ToString()
                                            $OPTWindowsDefenderATPEnabled     = $VDITemplate.Optimization.WindowsDefenderATPEnabled.ToString()    
                                            $OPTWindowsComponentsEnabled      = $VDITemplate.Optimization.WindowsComponentsEnabled.ToString()
                                            $OPTWindowsServicesEnabled        = $VDITemplate.Optimization.WindowsServicesEnabled.ToString()
                                            $OPTWinodwsScheduledTasksEnabled  = $VDITemplate.Optimization.WindowsScheduledTasksEnabled.ToString()
                                            $OPTWindowsAdvancedOptionsEnabled = $VDITemplate.Optimization.WindowsAdvancedOptionsEnabled.ToString()
                                            $OPTNetworkPerformanceEnabled     = $VDITemplate.Optimization.NetworkPerformanceEnabled.ToString()
                                            $OPTRegistryEnabled               = $VDITemplate.Optimization.RegistryEnabled.ToString()
                                            $OPTVisualEffectsEnabled          = $VDITemplate.Optimization.VisualEffectsEnabled.ToString()   
                                            $OPTDiskCleanupEnabled            = $VDITemplate.Optimization.DiskCleanupEnabled.ToString()
                                            $OPTCustomScriptEnabled           = $VDITemplate.Optimization.CustomScriptEnabled.ToString()
                                    }
     
                                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultUserProfileSettings.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Enable optimization"; Value = $OPTEnableOptimization; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Optimization type"; Value = $OPTOptimizationType; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 250;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
     
                                            WriteWordLine 5 0 "Windows Defender ATP:" $OPTWindowsDefenderATPEnabled
                                            If($OPTWindowsDefenderATPEnabled -eq "True")
 
  <>                                                 $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Defender ATP Optimizations"; Value = ""; }) > $Null
     
                                                    If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                    {
                                                            $ScriptInformation.Add(@{Data = "     Turn off Windows Defender ATP (I use my own ATP solution)"; Value = ""; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = "     Turn on Windows Defender ATP and set process and folder exclusions"; Value = ""; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "     Disable real-time protection"; Value = $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(); }) > $Null
                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                            
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "     Exclude files and folders"; Value = $item; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                    }
                                                            }
     
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "     Exclude processes"; Value = $item; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                    }
                                                            }
                                                            
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = "     Exclude extensions"; Value = $item; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                                                    }
                                                            }
                                                    }
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                $GatewaysWordTableRowHash = @{                                                   -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 250;
                                                    $Table.Columns.Item(2).Width = 250;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
     
                                            WriteWordLine 5 0 "Windows Components:" $OPTWindowsComponentsEnabled
                                            If($OPTWindowsComponentsEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Components Optimizations"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Disable (remove) components:"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                    {
                                                                    If($Null -eq $item.DisplayName)
                                                                    {
                                                        Gateway       = "$hostname ($ip)";                                                                           $DisplayName = ""
                                                        GatewayStatus = $HALBGWStatus;                                                                   }
                                                                    Else
                                                                    {
                                                                            $DisplayName = $item.DisplayName
                                                                    }
                                                                    If($Null -eq $item.ComponentName)
                                                                    {
                                                                            $ComponentName = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ComponentName = $item.ComponentName
                                                                    }
                                                            $OptimizationTable += @{
                                                                    DisplayName = $DisplayName
                                                                    ComponentName = $ComponentName
                                                            }
 
  <>  
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                $GatewaysWordTable += $GatewaysWordTableRowHash                                                           $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns DisplayName, ComponentName `
                                                            -Headers "Display name", "Component" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 200;
                                                            $Table.Columns.Item(2).Width = 200;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
 
  <>  
                                            WriteWordLine 5 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                            If($OPTWindowsServicesEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Services Optimizations"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Disable services:"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)
                                                    {
                                                                    If($Null -eq $item.DisplayName)
                                                                    {
                                                                            $DisplayName = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $DisplayName = $item.DisplayName
                                                                    }
                                                                    If($Null -eq $item.ServiceName)
                                                                    {
                                                                            $Service = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $Service = $item.ServiceName
                                                                    }
                                                                    If($Null -eq $item.Aliases)
                                                                    {
                                                                            $Aliases = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $Aliases = $item.Aliases
                                                                    }
                                                            $OptimizationTable += @{
                                                                    DisplayName = $DisplayName
                                                                    Service     = $Service
                                                                    Aliases     = $Aliases
                                                            }
                                                    }
     
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns DisplayName, Service, Aliases `
                                                            -Headers "Display name", "Service", "Aliases" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 200;
                                                            $Table.Columns.Item(2).Width = 100;
                                                            $Table.Columns.Item(3).Width = 50;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
                                            
                                            WriteWordLine 5 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                            If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Scheduled Tasks Optimizations"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Disable tasks:"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                                    {
                                        If($Text)                                                                   If($Null -eq $item.Task)
                                        {                                                                   {
                                                Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)                                                                           $Task = ""
                                        }                                                                   }
                                                                    Else
                                                                    {
                                                                            $Task = $item.Task
                                                                    }
                                                                    If($Null -eq $item.Type)
                                                                    {
                                                                            $Type = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $Type = $item.Type.ToString()
                                                                    }
                                                                    If($Null -eq $item.Location)
                                                                    {
                                                                            $Location = ""
                                                                    }
                                                                    Else
                                                                    {
                                                                            $Location = $item.Location
                                                                    }
                                                            $OptimizationTable += @{
                                                                    Task     = $Task
                                                                    Type     = $Type
                                                                    Location = $Location
                                                            }
                                                    }
                                        If($HTML)    
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Task, Type, Location `
                                                            -Headers "Task", "Type", "Location" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 200;
                                                            $Table.Columns.Item(2).Width = 50;
                                                            $Table.Columns.Item(3).Width = 250;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
                                            
                                            WriteWordLine 5 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                            If($OPTWindowsAdvancedOptionsEnabled -eq "True")
 
                                                $rowdata += @(,( <>                                                 $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Windows Advanced Options"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                "$hostname ($ip)",$htmlwhite,                                                   $OptimizationTable = @()
                                                $HALBGWStatus,$htmlwhite))                          
                                                    $OptimizationTable += @{
                                                            Setting = "Disable Hibernate"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString()
                                                            Value   = ""
                                        }                                                   }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable Telemetry collection"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString()
                                                            Value   = ""
                                }                                                   }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable System Restore"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable error reporting to send additional data"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable Tiles"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable Cortana digital assistant"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Turn off Microsoft consumer experience"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Do not show Windows tips"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Remove Common program groups from the Start Menu"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Partial Start Menu layout"
                                                            Enabled = $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString()
                                                            Value   = $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent
                                                    }
     
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Setting, Enabled, Value `
                                                            -Headers "Setting", "Enabled", "Value" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 275;
                                                            $Table.Columns.Item(2).Width = 50;
                                                            $Table.Columns.Item(3).Width = 175;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
                                                                          
                                #output the Word/PDF and HTML tables                                           WriteWordLine 5 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                If($MSWord -or $PDF)                                           If($OPTNetworkPerformanceEnabled -eq "True")
                                {                                           {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Network Performance Optimizations"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    $OptimizationTable += @{
                                                            Setting = "FileInfoCacheEntriesMax"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString()
                                                            Value   = $VDITemplate.Optimization.NetworkPerformance.FileInfoCache
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "DirectoryCacheEntriesMax"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString()
                                                            Value   = $VDITemplate.Optimization.NetworkPerformance.DirCacheMax
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "FileNotFoundCacheEntriesMax"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString()
                                                            Value   = $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "DormantFileLimit"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString()
                                                            Value   = $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable TCP/IP Task Offload"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable IPv6 Components"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disable IPv6 to IPv4"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString()
                                                            Value   = ""
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Disables isatap for IPv6"
                                                            Enabled = $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString()
                                                            Value   = ""
                                                    }
     
                                        If($GatewaysWordTable.Count -gt 0)                                                   If($OptimizationTable.Count -gt 0)
                                        {                                                   {
                                                $Table = AddWordTable -Hashtable $GatewaysWordTable `                                                           $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Setting, Enabled, Value `
                                                            -Headers "Setting", "Enabled", "Value" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 150;
                                                            $Table.Columns.Item(2).Width = 50;
                                                            $Table.Columns.Item(3).Width = 50;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
     
                                            WriteWordLine 5 0 "Registry: " $OPTRegistryEnabled
                                            If($OPTRegistryEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Registry Optimizations"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
     
                                                    ForEach($item in $VDITemplate.Optimization.Registry.RegistryList)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Registry"; Value = $item.DisplayName; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Action"; Value = $item.Action; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Value"; Value = $item.RegistryName; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Type"; Value = $item.RegType; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Data"; Value = $item.DWORDValue; }) > $Null
                                                            $ScriptInformation.Add(@{Data = "Path"; Value = "$($item.HiveType)\$($item.Path)"; }) > $Null
                                                            $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                                    }
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                -Columns  Gateway,GatewayStatus `                                                   -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 125;
                                                    $Table.Columns.Item(2).Width = 375;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                            
                                            WriteWordLine 5 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                            If($OPTVisualEffectsEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Visual Effects Optimizations"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 200;
                                                    $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    $OptimizationTable += @{
                                                            Setting = "Animate controls and elements inside windows"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Animate windows when minimizing and maximizing"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Animations in the taskbar"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Enable Peek"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Fade or slide menus into view"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Fade or slide Tooltips into view"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Fade out menu items after clicking"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Save taskbar thumbnail previews"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show shadows under mouse pointer"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show shadows under windows"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show thumbnails instead of icons"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show translucent selection rectangle"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Show window contents while dragging"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Slide open combo boxes"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Smooth edges of screen fonts"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Smooth-scroll list boxes"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Use drop shadows for icon labels on the desktop"
                                                            Enabled = $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString()
                                                    }
     
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Setting, Enabled `
                                                -Headers  "Gateways","Status"`                                                           -Headers "Setting", "Enabled" `
                                                -Format $wdTableGrid `                                                           -Format $wdTableGrid `
                                                -AutoFit $wdAutoFitFixed;                                                           -AutoFit $wdAutoFitFixed;
 
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15; <>                                                         SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
  -+                                                         $Table.Columns.Item(1).Width = 250;
                                                            $Table.Columns.Item(2).Width = 50;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
                                            
                                            WriteWordLine 5 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                            If($OPTDiskCleanupEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Disk Cleanup Optimizations"; Value = ""; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
 
  <>                                                 $Table.Columns.Item(2).Width = 15;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
     
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $OptimizationTable = @()
                            
                                                    $OptimizationTable += @{
                                                            Setting = "Clean up redundant system files"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Clean up the WinSxS Folder"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Clean up temporary files and logs"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Remove OneDrive"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString()
                                                    }
     
                                                    $OptimizationTable += @{
                                                            Setting = "Delete users' profiles"
                                                            Enabled = $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString()
                                                    }
     
                                                    If($OptimizationTable.Count -gt 0)
                                                    {
                                                            $Table = AddWordTable -Hashtable $OptimizationTable `
                                                            -Columns Setting, Enabled `
                                                            -Headers "Setting", "Enabled" `
                                                            -Format $wdTableGrid `
                                                            -AutoFit $wdAutoFitFixed;
     
                                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                            $Table.Columns.Item(1).Width = 175;
                                                $Table.Columns.Item(2).Width = 250;                                                           $Table.Columns.Item(2).Width = 50;
                                                            
                                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                            FindWordDocumentEnd
                                                            $Table = $Null
                                                            WriteWordLine 0 0 ""
                                                    }
                                            }
     
                                            WriteWordLine 5 0 "Custom script: " $OPTCustomScriptEnabled
                                            If($OPTCustomScriptEnabled -eq "True")
                                            {
                                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                    $ScriptInformation.Add(@{Data = "Custom Script"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Command"; Value = $VDITemplate.Optimization.CustomScript.Command; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Arguments"; Value = $VDITemplate.Optimization.CustomScript.Arguments; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Initial directory"; Value = $VDITemplate.Optimization.CustomScript.InitDir; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "     Username"; Value = $VDITemplate.Optimization.CustomScript.User; }) > $Null
     
                                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                                    -Columns Data,Value `
                                                    -List `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 100;
                                                    $Table.Columns.Item(2).Width = 200;
 
  -+                                         Line 3 "Inherit default settings`t: " $VDITemplate.InheritDefaultOptimizationSettings.ToString()
                                            Line 3 "Enable optimization`t`t: " $OPTEnableOptimization
                                            Line 3 "Optimization type`t`t: " $OPTOptimizationType
                                            Line 3 "Category"
                                            
                                            Line 4 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                            If($OPTWindowsDefenderATPEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Defender ATP Optimizations"
                                                    If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                    {
                                                            Line 6 "Turn off Windows Defender ATP (I use my own ATP solution)"
                                                    }
                                                    Else
                                                    {
                                                            Line 6 "Turn on Windows Defender ATP and set process and folder exclusions"
                                                            Line 6 "Disable real-time protection: " $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString()
                                                            Line 0 ""
                                                            Line 6 "Exclude files and folders:"
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                            {
                                                                    Line 7 $item
                                                            }
     
                                                            Line 6 "Exclude processes:"
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                            {
                                                                    Line 7 $item
                                                            }
                                                            
                                                            Line 6 "Exclude extensions:"
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                            {
                                                                    Line 7 $item
                                                            }
                                                    }
                                                    
                                                    Line 0 ""
                                            }
                                            
                                            Line 4 "Windows Components: " $OPTWindowsComponentsEnabled
                                            If($OPTWindowsComponentsEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Components Optimizations"
                                                    Line 6 "Disable (remove) components:"
                                                    Line 0 ""
                                                    Line 6 "Display name                                        Component                                         "
                                                    Line 6 "======================================================================================================"
                                                    #               12345678901234567890123456789012345678901234567890SS12345678901234567890123456789012345678901234567890
                                                    #               Printing-XPSServices-Features                       SMB 1.0/CIFS File sharing support component
                                                    ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                    {
                                                            Line 6 ( "{0,-50}  {1,-50}" -f $item.DisplayName, $item.ComponentName)
                                                    }
                                                    Line 0 ""
                                            }
                                            
                                            Line 4 "Windows Services: " $OPTWindowsServicesEnabled       
                                            If($OPTWindowsServicesEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Services Optimizations"
                                                    Line 6 "Disable services:"
                                                    Line 0 ""
                                                    Line 6 "Display name                                        Service                         Aliases             "
                                                    Line 6 "========================================================================================================"
                                                    #               12345678901234567890123456789012345678901234567890SS123456789012345678901234567890SS12345678901234567890
                                                    #               Windows Media Player Network Sharing Service        TabletInputService              Superfecth
                                                    ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)
                                                    {
                                                            Line 6 ( "{0,-50}  {1,-30}  {2,-20}" -f $item.DisplayName, $item.ServiceName, $item.Aliases)
                                                    }
                                                    Line 0 ""
                                            }
                                            
                                            Line 4 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled 
                                            If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Scheduled Tasks Optimizations"
                                                    Line 6 "Disable tasks:"
                                                    Line 0 ""
                                                    Line 6 "Task                                                Type    Location                                          "
                                                    Line 6 "=============================================================================================================="
                                                    #               12345678901234567890123456789012345678901234567890SS123456SS12345678901234567890123456789012345678901234567890
                                                    #               MNO Metadata Parser                                 Folder  \Microsoft\Windows\Mobile Broadband Accounts\
                                                    ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                                    {
                                                            Line 6 ( "{0,-50}  {1,-6}  {2,-50}" -f $item.Task, $item.Type.ToString(), $item.Location)
                                                    }
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                            If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                            {
                                                    Line 5 "Windows Advanced Options"
                                                    Line 0 ""
                                                    Line 6 "Setting                                           Enabled  Value                                             "
                                                    Line 6 "============================================================================================================="
                                                    #               123456789012345678901234567890123456789012345678SS1234567SS12345678901234567890123456789012345678901234567890
                                                    #               Remove Common program groups from the start menu  False    SomeConfigFile.xml
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable Hibernate", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable Telemetry collection", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable System Restore", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable error reporting to send additional data", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable Tiles", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Disable Cortana digital assistant", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Turn off Microsoft consumer experience", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Do not show Windows tips", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Remove Common program groups from the Start Menu", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-48}  {1,-7}  {2,-50}" -f `
                                                    "Partial Start Menu layout", `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(), `
                                                    $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent)
                                                    
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Network performance: " $OPTNetworkPerformanceEnabled
                                            If($OPTNetworkPerformanceEnabled -eq "True")
                                            {
                                                    Line 5 "Network Performance Optimizations"
                                                    Line 0 ""
                                                    Line 6 "Setting                      Enabled  Value"
                                                    Line 6 "==========================================="
                                                    #               123456789012345678901234567SS1234567SS12345
                                                    #               FileNotFoundCacheEntriesMax  False    32768
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "FileInfoCacheEntriesMax", `
                                                    $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(), `
                                                    $VDITemplate.Optimization.NetworkPerformance.FileInfoCache)
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "DirectoryCacheEntriesMax", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(), `
                                                    $VDITemplate.Optimization.NetworkPerformance.DirCacheMax)
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "FileNotFoundCacheEntriesMax", `
                                                    $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(), `
                                                    $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache)
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "DormantFileLimit", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(), `
                                                    $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit)
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "Disable TCP/IP Task Offload", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "Disable IPv6 Components", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "Disable IPv6 to IPv4", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(), `
                                                    "")
                                                    
                                                    Line 6 ( "{0,-27}  {1,-7}  {2,-5}" -f `
                                                    "Disables isatap for IPv6", `
                                                    $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(), `
                                                    "")
                                                    
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Registry: " $OPTRegistryEnabled
                                            If($OPTRegistryEnabled -eq "True")
                                            {
                                                    Line 5 "Registry Optimizations"
                                                    Line 0 ""
                                                    #               123456789012345678901234567SS1234567SS12345
                                                    #               FileNotFoundCacheEntriesMax  False    32768
                                                    Line 6 "Registry                                  Action  Value                 Type           Data                  Path                                                        "
                                                    Line 6 "========================================================================================================================================================================="
                                                    #               1234567890123456789012345678901234567890SS123456SS12345678901234567890SS1234567890123SS12345678901234567890SS123456789012345678901234567890123456789012345678901234567890
                                                    #               Increase service startup timeouts         Modify  99999999999999999999  REG_EXPAND_SZ  99999999999999999999  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Disk
                                                    ForEach($item in $VDITemplate.Optimization.Registry.RegistryList)
                                                    {
                                                            Line 6 ( "{0,-40}  {1,-6}  {2,-20}  {3,-13}  {4,-20}  {5,-60}" -f `
                                                            $item.DisplayName, $item.Action, $item.RegistryName, $item.RegType, $item.DWORDValue, "$($item.HiveType)\$($item.Path)")
                                                    }
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Visual Effects: " $OPTVisualEffectsEnabled
                                            If($OPTVisualEffectsEnabled -eq "True")
                                            {
                                                    Line 5 "Visual Effects Optimizations"
                                                    Line 0 ""
                                                    
                                                    Switch ($VDITemplate.Optimization.VisualEffects.VisualEffectsTypes)
                                                    {
                                                            "LetWindowsChooseWhatsBest"     {$VisualEffectsType = "Let Windows choose what's best"; Break}
                                                            "AdjustForBestAppearnce"        {$VisualEffectsType = "Adjust for best appearance"; Break} #misspelled in the PoSH output and the docs
                                                            "AdjustForBestPerformance"      {$VisualEffectsType = "Adjust for best performance"; Break}
                                                            "Custom"                                        {$VisualEffectsType = "Custom"; Break}
                                                            Default                                         {$VisualEffectsType = "Unable to determine Visual Effects Optimization type: $($VDITemplate.Optimization.VisualEffects.VisualEffectsTypes)"; Break}
                                                    }
                                                    Line 6 $VisualEffectsType
                                                    Line 0 ""
                                                    Line 6 "Setting                                             Enabled"
                                                    Line 6 "==========================================================="
                                                    #               12345678901234567890123456789012345678901234567890SS1234567
                                                    #               Use drop shadows for icon labels on the desktop     False  
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Animate controls and elements inside windows", `
                                                    $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Animate windows when minimizing and maximizing", `
                                                    $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Animations in the taskbar", `
                                                    $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Enable Peek", `
                                                    $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Fade or slide menus into view", `
                                                    $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Fade or slide Tooltips into view", `
                                                    $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Fade out menu items after clicking", `
                                                    $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Save taskbar thumbnail previews", `
                                                    $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show shadows under mouse pointer", `
                                                    $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show shadows under windows", `
                                                    $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show thumbnails instead of icons", `
                                                    $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show translucent selection rectangle", `
                                                    $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Show window contents while dragging", `
                                                    $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Slide open combo boxes", `
                                                    $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Smooth edges of screen fonts", `
                                                    $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Smooth-scroll list boxes", `
                                                    $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString())
                                                    
                                                    Line 6 ( "{0,-50}  {1,-7}" -f `
                                                    "Use drop shadows for icon labels on the desktop", `
                                                    $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString())
                                                    
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Disk cleanup: " $OPTDiskCleanupEnabled
                                            If($OPTDiskCleanupEnabled -eq "True")
                                            {
                                                    Line 5 "Disk Cleanup Optimizations"
                                                    Line 0 ""
                                                    
                                                    Line 6 "Setting                            Enabled"
                                                    Line 6 "=========================================="
                                                    #               123456789012345678901234567890123SS1234567
                                                    #               Clean up temporary files and logs  False  
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Clean up redundant system files", `
                                                    $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString())
                                                    
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Clean up the WinSxS Folder", `
                                                    $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString())
                                                    
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Clean up temporary files and logs", `
                                                    $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString())
                                                    
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Remove OneDrive", `
                                                    $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString())
                                                    
                                                    Line 6 ( "{0,-33}  {1,-7}" -f `
                                                    "Delete users' profiles", `
                                                    $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString())
                                                    
                                                    Line 0 ""
                                            }
     
                                            Line 4 "Custom script: " $OPTCustomScriptEnabled
                                            If($OPTCustomScriptEnabled  -eq "True")
                                            {
                                                    Line 5 "Custom Script"
                                                    Line 0 ""
                                                    
                                                    Line 6 "Command`t`t : " $VDITemplate.Optimization.CustomScript.Command
                                                    Line 6 "Arguments`t : " $VDITemplate.Optimization.CustomScript.Arguments
                                                    Line 6 "Initial directory: " $VDITemplate.Optimization.CustomScript.InitDir
                                                    Line 6 "Username`t : " $VDITemplate.Optimization.CustomScript.User
                                                    Line 0 ""
                                            }
 
  <>                                         $rowdata = @()
                                            $columnHeaders = @("Inherit default settings:",($Script:htmlsb),$VDITemplate.InheritDefaultOptimizationSettings.ToString(),$htmlwhite)
                                            $rowdata += @(,("Enable optimization:",($Script:htmlsb), $OPTEnableOptimization,$htmlwhite))
                                            $rowdata += @(,("Optimization type:",($Script:htmlsb), $OPTOptimizationType,$htmlwhite))
     
                                            $msg = "Optimization"
                                            $columnWidths = @("300","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
     
                                            WriteHTMLLine 4 0 "Windows Defender ATP: " $OPTWindowsDefenderATPEnabled
                                            If($OPTWindowsDefenderATPEnabled -eq "True")
                                            {
                                                    $rowdata = @()
                                                    $columnHeaders = @("Windows Defender ATP Optimizations",($Script:htmlsb),"",$htmlwhite)
     
                                                    If($VDITemplate.Optimization.WindowsDefenderATP.WinDefATPTurnOffOn.ToString() -eq "TurnOffWindowsDefenderATP")
                                                    {
                                                            $rowdata += @(,("     Turn off Windows Defender ATP (I use my own ATP solution)",($Script:htmlsb), "",$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("     Turn on Windows Defender ATP and set process and folder exclusions",($Script:htmlsb), "",$htmlwhite))
                                                            $rowdata += @(,("     Disable real-time protection",($Script:htmlsb), $VDITemplate.Optimization.WindowsDefenderATP.DisableRealTimeProtection.ToString(),$htmlwhite))
                                                            $rowdata += @(,("",($Script:htmlsb), "",$htmlwhite))
                                                            
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeFolders)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("     Exclude files and folders",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                            }
     
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeProcesses)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("     Exclude processes",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                            }
                                                            
                                                            $cnt = -1
                                                            ForEach($item in $VDITemplate.Optimization.WindowsDefenderATP.ExcludeExtension)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("     Exclude extensions",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb), $item,$htmlwhite))
                                                                    }
                                                            }
                                                    }
     
     
                                                    $msg = ""
                                                    $columnWidths = @("300","275")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Windows Components: " $OPTWindowsComponentsEnabled
                                            If($OPTWindowsComponentsEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Windows Components Optimizations"
     
                                                    $rowdata = @()
     
                                                    ForEach($item in $VDITemplate.Optimization.WindowsComponents.WindowsComponentsList)
                                                    {
                                                            $rowdata += @(,(
                                                                    $item.DisplayName,$htmlwhite,
                                                                    $item.ComponentName,$htmlwhite)
                                                            )
                                                    }
     
                                        $columnHeaders = @(                                                   $columnHeaders = @(
                                                            "Display Name",($Script:htmlsb),
                                                            "Component",($Script:htmlsb)
                                                    )
     
                                                    $msg = "Disable (remove) components:"
                                                    $columnWidths = @("200","200")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Windows Services: " $OPTWindowsServicesEnabled       
                                            If($OPTWindowsServicesEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Windows Services Optimizations"
     
                                                    $rowdata = @()
     
                                                    ForEach($item in $VDITemplate.Optimization.WindowsServices.WindowsServicesList)
                                                    {
                                                            $rowdata += @(,(
                                                                    $item.DisplayName,$htmlwhite,
                                                                    $item.ServiceName,$htmlwhite,
                                                                    $item.Aliases,$htmlwhite)
                                                            )
                                                    }
     
                                                    $columnHeaders = @(
                                                            "Display Name",($Script:htmlsb),
                                                            "Service",($Script:htmlsb),
                                                            "Aliases",($Script:htmlsb)
                                                    )
     
                                                    $msg = "Disable services:"
                                                    $columnWidths = @("200","100","50")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Windows Scheduled Tasks: " $OPTWinodwsScheduledTasksEnabled
                                            If($OPTWinodwsScheduledTasksEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Windows Scheduled Tasks Optimizations"
     
                                                    $rowdata = @()
     
                                                    ForEach($item in $VDITemplate.Optimization.WindowsScheduledTasks.WindowsScheduledTasksList)
                                                    {
                                                            $rowdata += @(,(
                                                                    $item.Task,$htmlwhite,
                                                                    $item.Type.Tostring(),$htmlwhite,
                                                                    $item.Location,$htmlwhite)
                                                            )
                                                    }
     
                                                    $columnHeaders = @(
                                                            "Task",($Script:htmlsb),
                                                            "Type",($Script:htmlsb),
                                                            "Location",($Script:htmlsb)
                                                    )
     
                                                    $msg = "Disable tasks:"
                                                    $columnWidths = @("200","50","250")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Windows advanced options: " $OPTWindowsAdvancedOptionsEnabled
                                            If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Windows Advanced Options"
     
                                                    $rowdata = @()
     
                                                    $rowdata += @(,(
                                                            "Disable Hibernate",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.Hibernate.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable Telemetry collection",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.TeleCollection.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable System Restore",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.SystemRestore.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable error reporting to send additional data",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.AdditionalErrorReport.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable Tiles",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.Tiles.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable Cortana digital assistant",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.Cortana.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Turn off Microsoft consumer experience",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.MicrosoftConsumerExperience.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Do not show Windows tips",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.WindowsTips.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Remove Common program groups from the Start Menu",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.CommonProgramGroups.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Partial Start Menu layout",$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartMenu.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.WindowsAdvancedOptions.PartialStartLayoutContent,$htmlwhite)
                                                    )
     
                                                    $columnHeaders = @(
                                                            "Setting",($Script:htmlsb),
                                                            "Enabled",($Script:htmlsb),
                                                            "Value",($Script:htmlsb)
                                                    )
     
                                                    $msg = ""
                                                    $columnWidths = @("300","50","200")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Network performance: " $OPTNetworkPerformanceEnabled
                                            If($OPTWindowsAdvancedOptionsEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Network Performance Optimizations"
     
                                                    $rowdata = @()
     
                                                    $rowdata += @(,(
                                                            "FileInfoCacheEntriesMax",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.FileInfoCacheEnable.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.FileInfoCache,$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "DirectoryCacheEntriesMax",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DirectoryCacheEnable.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DirCacheMax,$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "FileNotFoundCacheEntriesMax",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCacheEnable.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.FileNotFoundCache,$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "DormantFileLimit",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DormantFileLimitEnable.ToString(),$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DormantFileLimit,$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable TCP/IP Task Offload",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DisableTCP.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable IPv6 Components",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DisableIPv6CompEnable.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disable IPv6 to IPv4",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DisableIPv6ToIPv4.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Disables isatap for IPv6",$htmlwhite,
                                                            $VDITemplate.Optimization.NetworkPerformance.DisableIsaTap.ToString(),$htmlwhite,
                                                            "",$htmlwhite)
                                                    )
     
                                                    $columnHeaders = @(
                                                            "Setting",($Script:htmlsb),
                                                            "Enabled",($Script:htmlsb),
                                                            "Value",($Script:htmlsb)
                                                    )
     
                                                    $msg = ""
                                                    $columnWidths = @("170","50","50")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Registry: " $OPTRegistryEnabled       
                                            If($OPTRegistryEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Registry Optimizations"
     
                                                    $rowdata = @()
     
                                                    ForEach($item in $VDITemplate.Optimization.Registry.RegistryList)
                                                    {
                                                            $rowdata += @(,(
                                                                    $item.DisplayName,$htmlwhite,
                                                                    $item.Action,$htmlwhite,
                                                                    $item.RegistryName,$htmlwhite,
                                                                    $item.RegType,$htmlwhite,
                                                                    $item.DWORDValue,$htmlwhite,
                                                                    "$($item.HiveType)\$($item.Path)",$htmlwhite)
                                                            )
                                                    }
     
                                                    $columnHeaders = @(
                                                            "Registry",($Script:htmlsb),
                                                            "Action",($Script:htmlsb),
                                                            "Value",($Script:htmlsb),
                                                            "Type",($Script:htmlsb),
                                        "Gateways",($Script:htmlsb),                                                           "Data",($Script:htmlsb),
                                        "Status",($Script:htmlsb))                                                           "Path",($Script:htmlsb)
                                                    )
 
                                        $msg = "" <>                                                 $msg = ""
                                                    $columnWidths = @("200","50","100","100","100","200")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Visual Effects: " $OPTVisualEffectsEnabled
                                            If($OPTVisualEffectsEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Visual Effects Optimizations"
     
                                                    $rowdata = @()
     
                                                    $rowdata += @(,(
                                                            "Animate controls and elements inside windows",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.AnimateControlSelectElements.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Animate windows when minimizing and maximizing",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.AnimateWindowsWhenMinimizingMaximizing.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Animations in the taskbar",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.AnimateTaskbar.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Enable Peek",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.EnablePeek.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Fade or slide menus into view",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.FadeSlideMenus.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Fade or slide Tooltips into view",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.FadeSlideToolTips.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Fade out menu items after clicking",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.FadeOutMenuItems.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Save taskbar thumbnail previews",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.SaveTaskbarThumbnail.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show shadows under mouse pointer",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ShowShadowUnderMouse.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show shadows under windows",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ShadowUnderWindows.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show thumbnails instead of icons",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ThumbnailsInsteadOfIcons.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show translucent selection rectangle",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ShowTranslucentSelection.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Show window contents while dragging",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.ShowWindowsContentWhilstDragging.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Slide open combo boxes",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.SlideOpenComboBoxes.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Smooth edges of screen fonts",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.SmoothEdgesScreenFonts.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Smooth-scroll list boxes",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.SmoothScrollListBoxes.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Use drop shadows for icon labels on the desktop",$htmlwhite,
                                                            $VDITemplate.Optimization.VisualEffects.DropShadowsIcon.ToString(),$htmlwhite)
                                                    )
     
                                                    $columnHeaders = @(
                                                            "Setting",($Script:htmlsb),
                                                            "Enabled",($Script:htmlsb)
                                                    )
     
                                                    $msg = ""
                                                    $columnWidths = @("275","50")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Disk cleanup: " $OPTDiskCleanupEnabled
                                            If($OPTDiskCleanupEnabled -eq "True")
                                            {
                                                    WriteHTMLLine 0 0 "Disk Cleanup Optimizations"
     
                                                    $rowdata = @()
     
                                                    $rowdata += @(,(
                                                            "Clean up redundant system files",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.CleanupSystemFiles.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Clean up the WinSxS Folder",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.CleanupWinSxSFolder.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Clean up temporary files and logs",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.CleanupTemporaryFileLogs.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Remove OneDrive",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.RemoveOneDrive.ToString(),$htmlwhite)
                                                    )
     
                                                    $rowdata += @(,(
                                                            "Delete users' profiles",$htmlwhite,
                                                            $VDITemplate.Optimization.DiskCleanup.DeleteUserProfiles.ToString(),$htmlwhite)
                                                    )
     
                                                    $columnHeaders = @(
                                                            "Setting",($Script:htmlsb),
                                                            "Enabled",($Script:htmlsb)
                                                    )
     
                                                    $msg = ""
                                        $columnWidths = @("200","400")                                                   $columnWidths = @("200","50")
                                        FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"                                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                        WriteHTMLLine 0 0 ""                                                   WriteHTMLLine 0 0 ""
                                            }
     
                                            WriteHTMLLine 4 0 "Custom script: " $OPTCustomScriptEnabled
                                            If($OPTCustomScriptEnabled -eq "True")
                                            {
                                                    $rowdata = @()
                                                    $columnHeaders = @("Custom Script",($Script:htmlsb),"",$htmlwhite)
                                                    $rowdata += @(,("     Command",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.Command,$htmlwhite))
                                                    $rowdata += @(,("     Arguments",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.Arguments,$htmlwhite))
                                                    $rowdata += @(,("     Initial directory",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.InitDir,$htmlwhite))
                                                    $rowdata += @(,("     Username",($Script:htmlsb), $VDITemplate.Optimization.CustomScript.User,$htmlwhite))
     
                                                    $msg = ""
                                                    $columnWidths = @("125","200")
                                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                                    WriteHTMLLine 0 0 ""
                                            }
 
<# <>  
                                    #License Keys
                                    
 
                                        WriteWordLine 4 0 "Device Manager" <>                                         WriteWordLine 4 0 "License Keys"
 
                                        Line 2 "Device Manager" <>                                         Line 3 "License Keys"
 
                                        $ScriptInformation.Add(@{Data = "Port"; Value = ""; }) > $Null +-  
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }    
                                If($Text)    
                                {    
                                        Line 3 "Port: "    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Port",($Script:htmlsb),"",$htmlwhite)    
                                        $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))    
     
                                        $msg = "Device Manager"    
                                        $columnWidths = @("200","400")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
#>    
     
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "Devices"    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Devices"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                $HALBDevices = Get-RASHALBDevice -HALBName $HALB.Name -EA 0 4> $Null    
                                    
                                If((!$?) -or ($? -and $Null -eq $HALBDevices))    
                                {    
                                        Write-Host "    
                                        No HALB Devices retrieved for HALB $($HALB.Name).`    
                                        " -ForegroundColor White    
                                        If($MSWord -or $PDF)    
                                        {    
                                                WriteWordLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"    
                                        }    
                                        If($Text)    
                                        {    
                                                Line 0 "No HALB Devices retrieved for HALB $($HALB.Name)"    
                                        }    
                                        If($HTML)    
                                        {    
                                                WriteHTMLLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"    
                                        }    
                                }    
                                Else    
                                {    
                                        If($MSWord -or $PDF)    
                                        {    
                                                [System.Collections.Hashtable[]] $HALBDevicesWordTable = @();    
                                        }    
                                        If($Text)    
                                        {    
                                                Line 3 "Devices          ID"    
                                                Line 3 "==================="    
                                                #       999.999.999.999SS12    
                                        }    
                                        If($HTML)    
                                        {    
                                                $rowdata = @()    
                                        }    
 
                                        #process the gateways data <>                                         If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")
                                        ForEach($HALBDevice in $HALBDevices)    
 
                                                $ip = $HALBDevice.DeviceIP <>  
                                                $ID = $HALBDevice.DeviceId    
                                                    
                                                If($MSWord -or $PDF)    
                                                {    
                                                        $HALBDevicesWordTableRowHash = @{    
                                                                DeviceIP = $ip;    
                                                                DeviceID = $ID;    
                                                        }    
                                                        $HALBDevicesWordTable += $HALBDevicesWordTableRowHash    
                                                }    
                                                If($Text)    
                                                {    
                                                        Line 3 ( "{0,-15}  {1,-2}" -f $ip, $ID)    
                                                }    
                                                If($HTML)    
                                                {    
                                                        $rowdata += @(,(    
                                                        $ip,$htmlwhite,    
                                                        $ID,$htmlwhite))    
                                                }    
                                        }    
                                            
                                        #output the Word/PDF and HTML tables    
                                        If($MSWord -or $PDF)    
                                        {    
                                                If($HALBDevicesWordTable.Count -gt 0)    
                                                {    
                                                        $Table = AddWordTable -Hashtable $HALBDevicesWordTable `    
                                                        -Columns  DeviceIP,DeviceID `    
                                                        -Headers  "Devices","ID" `    
                                                        -Format $wdTableGrid `    
                                                        -AutoFit $wdAutoFitFixed;    
     
                                                        SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                        $Table.Columns.Item(1).Width = 100;    
                                                        $Table.Columns.Item(2).Width = 50;    
     
                                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                                        FindWordDocumentEnd    
                                                        $Table = $Null    
                                                        WriteWordLine 0 0 ""    
                                                }    
                                        }    
                                        If($Text)    
                                        {    
                                                Line 0 ""    
                                        }    
                                        If($HTML)    
                                        {    
                                                $columnHeaders = @(    
                                                "Devices",($Script:htmlsb),    
                                                "ID",($Script:htmlsb))    
     
                                                $msg = ""    
                                                $columnWidths = @("100","50")    
                                                FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "150"    
                                                WriteHTMLLine 0 0 ""    
                                        }    
                                }    
     
                                If($MSWord -or $PDF)    
                                {    
                                        WriteWordLine 4 0 "Advanced"    
                                }    
                                If($Text)    
                                {    
                                        Line 2 "Advanced"    
                                }    
                                If($HTML)    
                                {    
                                        #Nothing    
                                }    
                                    
                                If($MSWord -or $PDF)    
                                {    
                                        $ScriptInformation = New-Object System.Collections.ArrayList    
                                        $ScriptInformation.Add(@{Data = "Enable RDP UPD tunneling"; Value = $HALB.EnableUDPTunneling.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Maximum TCP connections"; Value = $HALB.MaxTCPConnections.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Client inactivity timeout (s)"; Value = $HALB.ClientIdleTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Gateway connection timeout (s)"; Value = $HALB.GWConnectionTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Client connection queue timeout (s)"; Value = $HALB.ClientQueueTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Gateway inactivity timeout (s)"; Value = $HALB.GatewayIdleTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Amount of TCP connections per second"; Value = $HALB.SessionsRate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Gateways health check intervals (s)"; Value = $HALB.GWHealthCheckInterval.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP virtual router ID"; Value = $HALB.VirtualRouterID.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP authentication password"; Value = ""; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP broadcast interval (m)"; Value = $HALB.VrrpBroadcastInterval.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP health check script interval (s)"; Value = $HALB.VrrpHealthCheckInterval.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP health check script timeout"; Value = $HALB.VrrpHealthCheckTimeout.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "VRRP advertisement interval (s)"; Value = $HALB.VrrpAdvertInterval.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Enable OS updates"; Value = $HALB.OSUpdate.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Keep existing load balancing settings"; Value = $HALB.KeepLBProxyConfig.ToString(); }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Keep existing VRRP/keepalive settings"; Value = $HALB.KeepVRRPConfig.ToString(); }) > $Null                                                   $ScriptInformation.Add(@{Data = "License key management type"; Value = "Key Management Service (KMS)"; }) > $Null
     
                                        $Table = AddWordTable -Hashtable $ScriptInformation `    
                                        -Columns Data,Value `    
                                        -List `    
                                        -Format $wdTableGrid `    
                                        -AutoFit $wdAutoFitFixed;    
     
                                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                        $Table.Columns.Item(1).Width = 200;    
                                        $Table.Columns.Item(2).Width = 250;    
     
                                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                        FindWordDocumentEnd    
                                        $Table = $Null    
                                        WriteWordLine 0 0 ""    
                                }                                           }
                                If($Text)    
                                {    
                                        Line 3 "Enable RDP UPD tunneling`t`t: " $HALB.EnableUDPTunneling.ToString()    
                                        Line 3 "Maximum TCP connections`t`t`t: " $HALB.MaxTCPConnections.ToString()    
                                        Line 3 "Client inactivity timeout (s)`t`t: " $HALB.ClientIdleTimeout.ToString()    
                                        Line 3 "Gateway connection timeout (s)`t`t: " $HALB.GWConnectionTimeout.ToString()    
                                        Line 3 "Client connection queue timeout (s)`t: " $HALB.ClientQueueTimeout.ToString()    
                                        Line 3 "Gateway inactivity timeout (s)`t`t: " $HALB.GatewayIdleTimeout.ToString()    
                                        Line 3 "Amount of TCP connections per second`t: " $HALB.SessionsRate.ToString()    
                                        Line 3 "Gateways health check intervals (s)`t: " $HALB.GWHealthCheckInterval.ToString()    
                                        Line 3 "VRRP virtual router ID`t`t`t: " $HALB.VirtualRouterID.ToString()    
                                        Line 3 "VRRP authentication password`t`t: "     
                                        Line 3 "VRRP broadcast interval (m)`t`t: " $HALB.VrrpBroadcastInterval.ToString()    
                                        Line 3 "VRRP health check script interval (s)`t: " $HALB.VrrpHealthCheckInterval.ToString()    
                                        Line 3 "VRRP health check script timeout`t: " $HALB.VrrpHealthCheckTimeout.ToString()    
                                        Line 3 "VRRP advertisement interval (s)`t`t: " $HALB.VrrpAdvertInterval.ToString()    
                                        Line 3 "Enable OS updates`t`t`t: " $HALB.OSUpdate.ToString()    
                                        Line 3 "Keep existing load balancing settings`t: " $HALB.KeepLBProxyConfig.ToString()    
                                        Line 3 "Keep existing VRRP/keepalive settings`t: " $HALB.KeepVRRPConfig.ToString()    
                                        Line 0 ""    
                                }    
                                If($HTML)    
                                {    
                                        $rowdata = @()    
                                        $columnHeaders = @("Enable RDP UPD tunneling",($Script:htmlsb),$HALB.EnableUDPTunneling.ToString(),$htmlwhite)    
                                        $rowdata += @(,("Maximum TCP connections",($Script:htmlsb),$HALB.MaxTCPConnections.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Client inactivity timeout (s)",($Script:htmlsb),$HALB.ClientIdleTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Gateway connection timeout (s)",($Script:htmlsb),$HALB.GWConnectionTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Client connection queue timeout (s)",($Script:htmlsb),$HALB.ClientQueueTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Gateway inactivity timeout (s)",($Script:htmlsb),$HALB.GatewayIdleTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Amount of TCP connections per second",($Script:htmlsb),$HALB.SessionsRate.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Gateways health check intervals (s)",($Script:htmlsb),$HALB.GWHealthCheckInterval.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP virtual router ID",($Script:htmlsb),$HALB.VirtualRouterID.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP authentication password",($Script:htmlsb),"",$htmlwhite))    
                                        $rowdata += @(,("VRRP broadcast interval (m)",($Script:htmlsb),$HALB.VrrpBroadcastInterval.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP health check script interval (s)",($Script:htmlsb),$HALB.VrrpHealthCheckInterval.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP health check script timeout",($Script:htmlsb),$HALB.VrrpHealthCheckTimeout.ToString(),$htmlwhite))    
                                        $rowdata += @(,("VRRP advertisement interval (s)",($Script:htmlsb),$HALB.VrrpAdvertInterval.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Enable OS updates",($Script:htmlsb),$HALB.OSUpdate.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Keep existing load balancing settings",($Script:htmlsb),$HALB.KeepLBProxyConfig.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Keep existing VRRP/keepalive settings",($Script:htmlsb),$HALB.KeepVRRPConfig.ToString(),$htmlwhite))    
     
                                        $msg = "Advanced"    
                                        $columnWidths = @("200","400")    
                                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                        WriteHTMLLine 0 0 ""    
                                }    
                        }    
                }    
        }    
            
        #Themes    
        $Themes = Get-RASTheme -Siteid $Site.Id -EA 0 4> $Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Themes for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve Themes for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Themes for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve Themes for Site $($Site.Name)"    
                }    
        }    
        ElseIf($? -and $Null -eq $Themes)    
        {    
                Write-Host "    
                No Themes retrieved for Site $($Site.Name).`    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No Themes retrieved for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "No Themes retrieved for Site $($Site.Name)"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Themes retrieved for Site $($Site.Name)"    
                }    
        }    
        Else                                           Else
        {                                           {
                If($MSWord -or $PDF)                                                   $ScriptInformation.Add(@{Data = "License key management type"; Value = "Multple Activation Key (MAK)"; }) > $Null
                {    
                        WriteWordLine 2 0 "Themes"    
                }    
                If($Text)    
                {    
                        Line 1 "Themes"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "Themes"    
                }    
     
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Themes"    
                ForEach($Theme in $Themes)    
                {    
                        $ThemePostLogonMessage        = $Theme.PostLogonMessage.Split("`n")    
                        $ThemeHTML5PrelogonMessage    = $Theme.HTML5Client.Message.PreLogonMessage.Split("`n")    
                        $ThemeHTML5PostlogonMessage   = $Theme.HTML5Client.Message.HTML5PostLogonMessage.Split("`n")    
                        $ThemeWindowsPostlogonMessage = $Theme.WindowsClient.Messages.WindowsClientPostLogonMessage.Split("`n")    
                        $ThemeHTML5URL                = "https://FQDN/$($Theme.HTML5Client.Url.LoginPageURLPath)"    
                        $ThemeShowDownloadURL         = $Theme.HTML5Client.Url.ShowDownloadURL.ToString()    
                        $ThemeOverrideDownloadURL     = $Theme.HTML5Client.Url.OverrideWindowsClientDownloadURL    
                        $ThemeFooterURLs              = @(Get-RASThemeFooterURL -Name $Theme.Name -EA 0) 4> $Null #fixed in 2.52 thanks to Thomas Krampe    
                                                                          
                        If(!$? -or $Null -eq $ThemeFooterURLs)    
                        {    
                                $ThemeFooterURLs = @()    
                        }    
                            
                        #the Get-RASThemeImage cmdlet returns all four items as an array, but there is nothing that    
                        #specifies which array element is which branding image file    
                        #I get each image file separately to make sure each image file is correctly associated    
                        $ThemeCompanyLogo = Get-RASThemeImage -Name $Theme.name -ImageType CompanyLogo -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                $ThemeCompanyLogo = ""    
                        }    
                            
                            
                        $ThemeFaviconIcon = Get-RASThemeImage -Name $Theme.name -ImageType FaviconIcon -EA 0 4>$Null                                                   $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null
                                                                          
                        If(!$?)    
                        {    
                                $ThemeFaviconIcon = ""                                                   ForEach($Item in $LicenseKeys)
                        }    
     
                            
                        $ThemeConnectionBanner = Get-RASThemeImage -Name $Theme.name -ImageType ConnectionBanner -EA 0 4>$Null    
                            
                        If(!$?)    
                        {                                                   {
                                $ThemeConnectionBanner = ""    
                        }    
     
                            
                        $ThemeApplicationIcon = Get-RASThemeImage -Name $Theme.name -ImageType ApplicationIcon -EA 0 4>$Null    
                            
                        If(!$?)    
                        {    
                                $ThemeApplicationIcon = ""    
                        }    
                            
                        $ThemeHTML5LaunchSessionsUsing = ""    
                        Switch($Theme.HTML5Client.Gateway.LaunchMethod)    
                        {    
                                "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"      
                                {    
                                        $ThemeHTML5LaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break    
                                }    
                                "Launch_Applications_with_Parallels_Client"                                                 
                                {    
                                        $ThemeHTML5LaunchSessionsUsing = "Launch apps with Parallels Client"; Break    
                                }    
                                "Launch_Applications_with_Browser_HTML5"                                                    
                                {    
                                        $ThemeHTML5LaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break    
                                }    
                                Default                                                                                                                     
                                {    
                                        $ThemeHTML5LaunchSessionsUsing = "Unable to determine Launch sessions using: $($Theme.HTML5Client.Gateway.LaunchMethod)"; Break    
                                }    
                        }    
                            
                        $ThemeHTMLFileTransfer = ""    
                        Switch($Theme.HTML5Client.Gateway.FileTransferMode)    
                        {    
                                "Disabled"                      {$ThemeHTMLFileTransfer = "Disabled"; Break}    
                                "ClientToServer"        {$ThemeHTMLFileTransfer = "Client to server only"; Break}    
                                "ServerToClient"        {$ThemeHTMLFileTransfer = "Server to client only"; Break}    
                                "Bidirectional"         {$ThemeHTMLFileTransfer = "Bidirectional"; Break}    
                                Default                         {$ThemeHTMLFileTransfer = "Unable to determine File transfer mode: $($Theme.HTML5Client.Gateway.FileTransferMode)"; Break}    
                        }    
                            
                        $ThemeHTMLClipboardDirection = ""    
                        Switch($Theme.HTML5Client.Gateway.ClipboardDirection)    
                        {    
                                "None"                          {$ThemeHTMLClipboardDirection = "None"; Break}    
                                "ClientToServer"        {$ThemeHTMLClipboardDirection = "Client to server only"; Break}    
                                "ServerToClient"        {$ThemeHTMLClipboardDirection = "Server to client only"; Break}    
                                "Bidirectional"         {$ThemeHTMLClipboardDirection = "Bidirectional"; Break}    
                                Default                         {$ThemeHTMLClipboardDirection = "Unable to determine Clipboard direction: $($Theme.HTML5Client.Gateway.ClipboardDirection)"; Break}    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 3 0 "Theme $($Theme.Name)"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $Theme.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $Theme.Description; }) > $Null                                                           $ScriptInformation.Add(@{Data = "License Key"; Value = $Item.LicenseKey; }) > $Null
                                $ScriptInformation.Add(@{Data = "HTML5 URL"; Value = $ThemeHTML5URL; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Theme.AdminLastMod; }) > $Null                                                           $ScriptInformation.Add(@{Data = "Key Limit"; Value = $Item.KeyLimit; }) > $Null
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $Theme.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $Theme.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $Theme.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "ID"; Value = $Theme.Id.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 2 "Theme $($Theme.Name)"    
                                Line 3 "Name`t`t`t: " $Theme.Name    
                                Line 3 "Description`t`t: " $Theme.Description    
                                Line 3 "HTML5 URL`t`t: " $ThemeHTML5URL    
                                Line 3 "Last modification by`t: " $Theme.AdminLastMod    
                                Line 3 "Modified on`t`t: " $Theme.TimeLastMod.ToString()    
                                Line 3 "Created by`t`t: " $Theme.AdminCreate    
                                Line 3 "Created on`t`t: " $Theme.TimeCreate.ToString()    
                                Line 3 "ID`t`t`t: " $Theme.Id.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $ThemeName = $Theme.Name.Replace("<","").Replace(">","")    
                                WriteHTMLLine 3 0 "Theme $ThemeName"    
                                $rowdata = @()    
                                $columnHeaders = @("Name",($Script:htmlsb),$ThemeName,$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))    
                                $rowdata += @(,("HTML5 URL",($Script:htmlsb),$ThemeHTML5URL,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $Theme.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $Theme.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $Theme.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb), $Theme.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("ID",($Script:htmlsb),$Theme.Id.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "General"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "General"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Enable Theme"; Value = $Theme.Enabled.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $Theme.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $Theme.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Override authentication domain"; Value = $Theme.OverrideAuthenticationDomain.ToString(); }) > $Null    
                                If($Theme.OverrideAuthenticationDomain)    
                                {    
                                        $ScriptInformation.Add(@{Data = "     Domain"; Value = $Theme.Domain; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "Limit access to this theme to members of these AD groups"; Value = $Theme.GroupEnabled.ToString(); }) > $Null    
                                If($Theme.GroupEnabled)    
                                {    
                                        ForEach($Group in $Theme.GroupFilters)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Group: $($Group.name) SID: $($Group.sid)"; }) > $Null    
                                        }                                                   }
                                }                                           }
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Enable Theme`t`t`t: " $Theme.Enabled.ToString()                                           If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")
                                Line 3 "Name`t`t`t`t: " $Theme.Name    
                                Line 3 "Description`t`t`t: " $Theme.Description    
                                Line 3 "Override authentication domain`t: " $Theme.OverrideAuthenticationDomain.ToString()    
                                If($Theme.OverrideAuthenticationDomain)    
                                {                                           {
                                        Line 6 "Domain  : " $Theme.Domain                                                   Line 4 "License key management type: " "Key Management Service (KMS)"
                                }                                           }
                                Line 3 "Limit access to this theme to "                                           Else
                                Line 3 "members of these AD groups`t: " $Theme.GroupEnabled.ToString()    
                                If($Theme.GroupEnabled)    
                                {                                           {
                                                    Line 4 "License key management type: " "Multple Activation Key (MAK)"
                                                    
                                                    $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null
     
                                        ForEach($Group in $Theme.GroupFilters)                                                   ForEach($Item in $LicenseKeys)
                                        {                                                   {
                                                Line 7 "  Group: $($Group.name) SID: $($Group.sid)"                                                           Line 4 "License Key`t: " $Item.LicenseKey
                                                            Line 4 "Key Limit`t: " $Item.KeyLimit
                                        }                                                   }
                                }                                           }
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                $ThemeName = $Theme.Name.Replace("<","").Replace(">","")    
                                $rowdata = @()                                           $rowdata = @()
                                            If($VDITemplate.LicenseKeyType.ToString() -eq "KMS")
                                            {
                                $columnHeaders = @("Enable Theme",($Script:htmlsb),$Theme.Enabled.ToString(),$htmlwhite)                                                   $columnHeaders = @("License key management type",($Script:htmlsb),"Key Management Service (KMS)",$htmlwhite)
                                            }
                                            Else
                                            {
                                $rowdata += @(,("Name",($Script:htmlsb),$ThemeName,$htmlwhite))                                                   $columnHeaders = @("License key management type",($Script:htmlsb),"Multple Activation Key (MAK)",$htmlwhite)
                                                    
                                                    $LicenseKeys = Get-RASVDITemplateLicenseKey -Id $VDITemplate.Id -EA 0 4>$Null
     
                                                    $cnt = -1
                                                    ForEach($Item in $LicenseKeys)
                                                    {
                                $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))                                                           $rowdata += @(,("License Key",($Script:htmlsb),$Item.LicenseKey,$htmlwhite))
                                $rowdata += @(,("Override authentication domain",($Script:htmlsb),$Theme.OverrideAuthenticationDomain.ToString(),$htmlwhite))                                                           $rowdata += @(,("Key Limit",($Script:htmlsb),$Item.KeyLimit,$htmlwhite))
                                                    }
                                            }
     
                                            $msg = "License Keys"
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                                    
                                    #Settings
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 4 0 "Settings"
                                    }
                                    If($Text)
                                    {
                                            Line 3 "Settings"
                                    }
                                    If($HTML)
                                    {
                                            #Nothing
                                    }
                                    
                                If($Theme.OverrideAuthenticationDomain)                                   If($VDITemplate.InheritDefaultVDIActionSettings)
 
                                        $rowdata += @(,("     Domain",($Script:htmlsb),$Theme.Domain,$htmlwhite)) <>                                         #do we inherit site defaults?
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
     
                                            $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                            
                                            If($? -and $Null -ne $VDIDefaults)
                                            {
                                                    Switch ($VDIDefaults.SessionResetTimeoutSec)
                                                    {
                                                            0               {$VDITemplateLogoffActiveSessionAfter = "Never"; Break}
                                                            1               {$VDITemplateLogoffActiveSessionAfter = "Immediate"; Break}
                                                            25              {$VDITemplateLogoffActiveSessionAfter = "25 seconds"; Break}
                                                            60              {$VDITemplateLogoffActiveSessionAfter = "1 minute"; Break}
                                                            300             {$VDITemplateLogoffActiveSessionAfter = "5 minutes"; Break}
                                                            3600    {$VDITemplateLogoffActiveSessionAfter = "1 hour"; Break}
                                                            7200    {$VDITemplateLogoffActiveSessionAfter = "2 hours"; Break}
                                                            Default {$VDITemplateLogoffActiveSessionAfter = "Unable to determine Logoff active session after: $($VDIDefaults.SessionResetTimeoutSec)"; Break}
                                                    }
                                                    
                                                    Switch ($VDIDefaults.PerformActionAfterSec)
                                                    {
                                                            0               {$VDITemplateActionsAfter = "Never"; Break}
                                                            1               {$VDITemplateActionsAfter = "Immediate"; Break}
                                                            25              {$VDITemplateActionsAfter = "25 seconds"; Break}
                                                            60              {$VDITemplateActionsAfter = "1 minute"; Break}
                                                            300             {$VDITemplateActionsAfter = "5 minutes"; Break}
                                                            3600    {$VDITemplateActionsAfter = "1 hour"; Break}
                                                            7200    {$VDITemplateActionsAfter = "2 hours"; Break}
                                                            Default {$VDITemplateActionsAfter = "Unable to determine Actions After: $($VDIDefaults.PerformActionAfterSec)"; Break}
                                                    }
                                                    $VDITemplateActionsOnSession         = $VDIDefaults.SessionAction.ToString()
                                                    $VDITemplateActionsPerformAction     = $VDIDefaults.PerformAction.ToString()
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $VDITemplateLogoffActiveSessionAfter = "Never"
                                                    $VDITemplateActionsOnSession         = "Disconnect"
                                                    $VDITemplateActionsPerformAction     = "Do nothing"
                                                    $VDITemplateActionsAfter             = "Never"
                                            }
 
  <>                                 Else
                                    {
                                            #No, we don't use the VDI Template settings
                                            Switch ($VDITemplate.SessionResetTimeoutSec)
                                            {
                                                    0               {$VDITemplateLogoffActiveSessionAfter = "Never"; Break}
                                                    1               {$VDITemplateLogoffActiveSessionAfter = "Immediate"; Break}
                                                    25              {$VDITemplateLogoffActiveSessionAfter = "25 seconds"; Break}
                                                    60              {$VDITemplateLogoffActiveSessionAfter = "1 minute"; Break}
                                                    300             {$VDITemplateLogoffActiveSessionAfter = "5 minutes"; Break}
                                                    3600    {$VDITemplateLogoffActiveSessionAfter = "1 hour"; Break}
                                                    7200    {$VDITemplateLogoffActiveSessionAfter = "2 hours"; Break}
                                $rowdata += @(,("Limit access to this theme to members of these AD groups",($Script:htmlsb),$Theme.GroupEnabled.ToString(),$htmlwhite))                                                   Default {$VDITemplateLogoffActiveSessionAfter = "Unable to determine Logoff active session after: $($VDITemplate.SessionResetTimeoutSec)"; Break}
                                If($Theme.GroupEnabled)                                           }
                                            
                                            Switch ($VDITemplate.PerformActionAfterSec)
                                {                                           {
                                        ForEach($Group in $Theme.GroupFilters)                                                   0               {$VDITemplateActionsAfter = "Never"; Break}
                                                    1               {$VDITemplateActionsAfter = "Immediate"; Break}
                                                    25              {$VDITemplateActionsAfter = "25 seconds"; Break}
                                                    60              {$VDITemplateActionsAfter = "1 minute"; Break}
                                                    300             {$VDITemplateActionsAfter = "5 minutes"; Break}
                                                    3600    {$VDITemplateActionsAfter = "1 hour"; Break}
                                                    7200    {$VDITemplateActionsAfter = "2 hours"; Break}
                                                    Default {$VDITemplateActionsAfter = "Unable to determine Actions After: $($VDITemplate.PerformActionAfterSec)"; Break}
                                            }
                                            $VDITemplateActionsOnSession         = $VDITemplate.SessionAction.ToString()
                                            $VDITemplateActionsPerformAction     = $VDITemplate.PerformAction.ToString()
                                    }
                                    
                                    If($MSWord -or $PDF)
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),"Group: $($Group.name) SID: $($Group.sid)",$htmlwhite))                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultVDIActionSettings.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Application session lingering"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Logoff active session after"; Value = $VDITemplateLogoffActiveSessionAfter; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Actions"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     On session"; Value = $VDITemplateActionsOnSession; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Perform action"; Value = $VDITemplateActionsPerformAction; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     After"; Value = $VDITemplateActionsAfter; }) > $Null
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                        }                                   }
                                    If($Text)
                                    {
                                            Line 4 "Inherit default settings`t`t: " $VDITemplate.InheritDefaultVDIActionSettings.ToString()
                                            Line 4 "Application session lingering"
                                            Line 5 "Logoff active session after`t: " $VDITemplateLogoffActiveSessionAfter
                                            Line 4 "Actions"
                                            Line 5 "On session`t`t`t: " $VDITemplateActionsOnSession
                                            Line 5 "Perform action`t`t`t: " $VDITemplateActionsPerformAction
                                            Line 5 "After`t`t`t`t: " $VDITemplateActionsAfter
                                            Line 0 ""
 
  -+                                 If($HTML)
                                    {
 
  <>                                         $rowdata = @()
                                            $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultVDIActionSettings.ToString(),$htmlwhite)
                                            $rowdata += @(,("Application session lingering",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "     Logoff active session after",($Script:htmlsb),$VDITemplateLogoffActiveSessionAfter,$htmlwhite))
                                            $rowdata += @(,( "Actions",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,( "     On session",($Script:htmlsb),$VDITemplateActionsOnSession,$htmlwhite))
                                            $rowdata += @(,( "     Perform action",($Script:htmlsb),$VDITemplateActionsPerformAction,$htmlwhite))
                                            $rowdata += @(,( "     After",($Script:htmlsb),$VDITemplateActionsAfter,$htmlwhite))
     
                                $msg = "General"                                           $msg = "Settings"
                                $columnWidths = @("200","400")                                           $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
     
                                    #Security
                                                          
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                        {                                   {
                                WriteWordLine 4 0 "Messages"                                           WriteWordLine 4 0 "Security"
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 2 "Messages"                                           Line 3 "Security"
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                #Nothing                                           #Nothing
                                    }
                                    
                                    If($VDITemplate.InheritDefaultVDISecuritySettings)
                                    {
                                            #do we inherit site defaults?
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
     
                                            $VDIDefaults = Get-RASVDIDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                            
                                            If($? -and $Null -ne $VDIDefaults)
                                            {
                                                    $VDITemplateGrantPermissions  = $VDIDefaults.IsUsersGrantedRDPermissions.ToString()
                                                    If($VDIDefaults.GroupType -eq "Administrators")
                                                    {
                                                            $VDITemplateSecurityGroup = "Administrators"
                                                    }
                                                    Else
                                                    {
                                                            $VDITemplateSecurityGroup = "Remote Desktop Users group"
                                                    }
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $VDITemplateGrantPermissions = "False"
                                                    $VDITemplateSecurityGroup    = ""
                                            }
                                    }
                                    Else
                                    {
                                            #No, we don't use the VDI Template settings
                                            $VDITemplateGrantPermissions  = $VDITemplate.IsUsersGrantedRDPermissions.ToString()
                                            If($VDITemplate.GroupType -eq "Administrators")
                                            {
                                                    $VDITemplateSecurityGroup = "Administrators"
                                            }
                                            Else
                                            {
                                                    $VDITemplateSecurityGroup = "Remote Desktop Users group"
                                            }
                                    }
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $VDITemplate.InheritDefaultVDISecuritySettings.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Grant users Remote Desktop connection permissions"; Value = $VDITemplateGrantPermissions; }) > $Null
                                            If($VDITemplateGrantPermissions -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Local security group"; Value = $VDITemplateSecurityGroup; }) > $Null
                                            }
     
                                            $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    If($Text)
                                    {
                                            Line 4 "Inherit default settings`t`t`t : " $VDITemplate.InheritDefaultVDISecuritySettings.ToString()
                                            Line 4 "Grant users Remote Desktop connection permissions: " $VDITemplateGrantPermissions
                                            If($VDITemplateGrantPermissions -eq "True")
                                            {
                                                    Line 5 "Local security group`t`t`t : " $VDITemplateSecurityGroup
                                            }
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
     
                                            $rowdata = @()
                                            $columnHeaders = @("Inherit default settings",($Script:htmlsb),$VDITemplate.InheritDefaultVDISecuritySettings.ToString(),$htmlwhite)
                                            $rowdata += @(,( "Grant users Remote Desktop connection permissions",($Script:htmlsb),$VDITemplateGrantPermissions,$htmlwhite))
                                            If($VDITemplateGrantPermissions -eq "True")
                                            {
                                                    $rowdata += @(,( "Local security group",($Script:htmlsb),$VDITemplateSecurityGroup,$htmlwhite))
                                            }
     
                                            $msg = "Security"
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
 
  -+  
                    }
                    
                    #Write-Verbose "$(Get-Date -Format G): `tOutput VDI Desktops"
                    #Desktops
                    ###ADD LATER
                    
                    #Write-Verbose "$(Get-Date -Format G): `tOutput VDI Scheduler"
                    #Scheduler
                    #not in PoSH
            }
            
            #Providers
            Write-Verbose "$(Get-Date -Format G): Output Providers"
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Providers"
            }
            If($Text)
            {
                    Line 1 "Providers"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Providers"
            }
     
            $Providers = Get-RASProvider -SiteId $Site.Id -EA 0 4>$Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Providers for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Providers for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Providers for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $Providers)
            {
                    Write-Host "
                    No Providers retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Providers retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Providers retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Providers retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Providers"
                    ForEach($Provider in $Providers)
                    {
                            $ProviderStatus = Get-RASProviderStatus -Id $Provider.Id -EA 0 4>$Null
 
  <>                         If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve Provider Status for Provider $($Provider.Id)`
                                    "
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve Provider Status for Provider $($Provider.Id)"
                                    }
                            }
                            ElseIf($? -and $Null -eq $ProviderStatus)
 
  <>                                 Write-Host "
                                    No Provider Status retrieved for Provider $($Provider.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No Provider Status retrieved for Provider $($Provider.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No Provider Status retrieved for Provider $($Provider.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No Provider Status retrieved for Provider $($Provider.Id)"
                                    }
                            }
                            Else
                            {
                                    $FullProviderStatus = GetRASStatus $ProviderStatus.AgentState
     
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Provider $($Provider.Name)"
                                    }
                                    If($Text)
                                    {
                                            Line 2 "Provider $($Provider.Name)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 3 0 "Provider $($Provider.Name)"
                                    }
     
                                    $VDIType = GetVDIType $Provider.Type
                                    
                                    Switch($ProviderStatus.HighAvailabilityState)
                                    {
                                            "Off"           {$HAMode = "Off"; Break}
                                            "On_Pref"       {$HAMode = "On (Preferred)"; Break}
                                            "On_Auto"       {$HAMode = "On (Auto)"; Break}
                                            Default         {$HAMode = "Unable to determine High Availability mode: $($ProviderStatus.HighAvailabilityState)"; Break}
                                    }
                                    
                                    If($MSWord -or $PDF)
                                    {
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Enabled"; Value = $Provider.Enabled.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $FullProviderStatus; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Provider Agent"; Value = $Provider.VDIAgent; }) > $Null
                                            $ScriptInformation.Add(@{Data = "High availability"; Value = $HAMode; }) > $Null
                                            If($VDIType -like "*azure*")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $Provider.VDIAzureCloudInfo.TenantID; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $Provider.VDIAzureCloudInfo.SubscriptionID; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "Tenant ID"; Value = ""; }) > $Null
                                                    $ScriptInformation.Add(@{Data = "Subscription ID"; Value = ""; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "Application ID"; Value = $Provider.VDIUsername; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Log level"; Value = $ProviderStatus.LogLevel; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Provider.AdminLastMod; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Modified on"; Value = $Provider.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $Provider.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $Provider.TimeCreate.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "ID"; Value = $Provider.Id.ToString(); }) > $Null
                                $cnt = -1    
                                ForEach($line in $ThemePostLogonMessage)                                           $Table = AddWordTable -Hashtable $ScriptInformation `
                                            -Columns Data,Value `
                                            -List `
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                                    If($Text)
 
  <>                                         Line 3 "Name`t`t`t: " $Provider.Name
                                            Line 3 "Enabled`t`t`t: " $Provider.Enabled.ToString()
                                            Line 3 "Status`t`t`t: " $FullProviderStatus
                                            Line 3 "Type`t`t`t: " $VDIType
                                            Line 3 "Description`t`t: " $Provider.Description
                                            Line 3 "Provider Agent`t`t: " $Provider.VDIAgent
                                            Line 3 "High availability`t: " $HAMode
                                            If($VDIType -like "*azure*")
                                            {
                                                    Line 3 "Tenant ID`t`t: " $Provider.VDIAzureCloudInfo.TenantID
                                                    Line 3 "Subscription ID`t`t: " $Provider.VDIAzureCloudInfo.SubscriptionID
                                            }
                                            Else
                                            {
                                                    Line 3 "Tenant ID`t`t: "
                                                    Line 3 "Subscription ID`t`t: "
                                            }
                                            Line 3 "Application ID`t`t: " $Provider.VDIUsername
                                            Line 3 "Log level`t`t: " $ProviderStatus.LogLevel
                                            Line 3 "Last modification by`t: " $Provider.AdminLastMod
                                            Line 3 "Modified on`t`t: " $Provider.TimeLastMod.ToString()
                                            Line 3 "Created by`t`t: " $Provider.AdminCreate
                                            Line 3 "Created on`t`t: " $Provider.TimeCreate.ToString()
                                            Line 3 "ID`t`t`t: " $Provider.Id.ToString()
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
                                            $rowdata = @()
                                            $columnHeaders = @("Name",($Script:htmlsb),$Provider.Name,$htmlwhite)
                                            $rowdata += @(,("Enabled",($Script:htmlsb),$Provider.Enabled.ToString(),$htmlwhite))
                                            $rowdata += @(,("Status",($Script:htmlsb),$FullProviderStatus,$htmlwhite))
                                            $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))
                                            $rowdata += @(,("Description",($Script:htmlsb),$Provider.Description,$htmlwhite))
                                            $rowdata += @(,("Provider Agent",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite))
                                            If($VDIType -like "*azure*")
                                            {
                                                    $rowdata += @(,("Tenant ID",($Script:htmlsb),$Provider.VDIAzureCloudInfo.TenantID,$htmlwhite))
                                                    $rowdata += @(,("Subscription ID",($Script:htmlsb),$Provider.VDIAzureCloudInfo.SubscriptionID,$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("Tenant ID",($Script:htmlsb),"",$htmlwhite))
                                                    $rowdata += @(,("Subscription ID",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            $rowdata += @(,("Application ID",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite))
                                            $rowdata += @(,("Log level",($Script:htmlsb),$ProviderStatus.LogLevel,$htmlwhite))
                                            $rowdata += @(,("Last modification by",($Script:htmlsb), $Provider.AdminLastMod,$htmlwhite))
                                            $rowdata += @(,("Modified on",($Script:htmlsb), $Provider.TimeLastMod.ToString(),$htmlwhite))
                                            $rowdata += @(,("Created by",($Script:htmlsb), $Provider.AdminCreate,$htmlwhite))
                                            $rowdata += @(,("Created on",($Script:htmlsb), $Provider.TimeCreate.ToString(),$htmlwhite))
                                            $rowdata += @(,("Id",($Script:htmlsb),$Provider.Id.ToString(),$htmlwhite))
                                        $cnt++    
                                            $msg = ""
                                            $columnWidths = @("200","275")
                                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
                                                                  
                            #General
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "General"
                            }
                                        If($cnt -eq 0)                           If($Text)
                            {
                                    Line 3 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If(validobject $Provider PreferredBrokerId)
                            {
                                    $HostPA = Get-RASBroker -Id $Provider.PreferredBrokerId -EA 0 4>$Null
                            }
                            Else
                            {
                                    $HostPA = $Null
                                    $DedicatedVDIAgent = $False
                            }
                            
                            If($? -and -$Null -ne $HostPA)
                            {
                                    If(validobject $HostPA Server)
                                    {
                                            If($Provider.VDIAgent -eq $HostPa.Server)
 
  <>                                                 $DedicatedVDIAgent = $False
                                            }
                                            Else
                                            {
                                                    $DedicatedVDIAgent = $True
                                            }
                                    }
                                    Else
                                    {
                                            $DedicatedVDIAgent = $False
                                    }
                            }
                            ElseIf($? -and $Null -eq $HostPA)
                            {
                                    $DedicatedVDIAgent = $False
                            }
                            Else
                            {
                                    $DedicatedVDIAgent = $False
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Enable provider in site"; Value = $Provider.Enabled.ToString(); }) > $Null
                                    If($VDIType -eq "Azure")
                                    {
                                            $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null
                                                $ScriptInformation.Add(@{Data = "Post-logon message:"; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Subscription details"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Authentication URL"; Value = $Provider.VDIAzureCloudInfo.AuthenticationURL; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Management URL"; Value = $Provider.VDIAzureCloudInfo.ManagementURL; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Resource URI"; Value = $Provider.VDIAzureCloudInfo.ResourceURI; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Tenant ID"; Value = $Provider.VDIAzureCloudInfo.TenantID; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Subscription ID"; Value = $Provider.VDIAzureCloudInfo.SubscriptionID; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                            $ScriptInformation.Add(@{Data = "Name"; Value = $Provider.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $Provider.Description; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Type"; Value = $VDIType; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Host"; Value = $Provider.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Port"; Value = $Provider.VDIPort.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Resource pool"; Value = $Provider.ResourcePool; }) > $Null
                                        }                                   }
                                    $ScriptInformation.Add(@{Data = "Dedicated Provider Agent"; Value = $DedicatedVDIAgent.ToString(); }) > $Null
                                    If($DedicatedVDIAgent)
                                    {
                                            $ScriptInformation.Add(@{Data = "Agent address"; Value = $Provider.VDIAgent; }) > $Null
 
                                $cnt = -1 <>                                 Line 4 "Enable provider in site`t`t: " $Provider.Enabled.ToString()
                                ForEach($line in $ThemePostLogonMessage)                                   If($VDIType -eq "Azure")
 
                                        $cnt++ <>                                         Line 4 "Type`t`t`t`t: " $VDIType
                                                                                  Line 4 "Name`t`t`t`t: " $Provider.Name
                                        If($cnt -eq 0)                                           Line 4 "Description`t`t`t: " $Provider.Description
                                        {                                           Line 4 "Subscription details`t`t: " 
                                                Line 3 "Post-logon message: " $line                                           Line 5 "Authentication URL: " $Provider.VDIAzureCloudInfo.AuthenticationURL
                                            Line 5 "Management URL`t  : " $Provider.VDIAzureCloudInfo.ManagementURL
                                            Line 5 "Resource URI`t  : " $Provider.VDIAzureCloudInfo.ResourceURI
                                            Line 4 "Tenant ID`t`t`t: " $Provider.VDIAzureCloudInfo.TenantID
                                            Line 4 "Subscription ID`t`t`t: " $Provider.VDIAzureCloudInfo.SubscriptionID
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 5   " $line                                           Line 4 "Name`t`t`t`t: " $Provider.Name
                                            Line 4 "Description`t`t`t: " $Provider.Description
                                            Line 4 "Type`t`t`t`t: " $VDIType
                                            Line 4 "Host`t`t`t`t: " $Provider.Server
                                            Line 4 "Port`t`t`t`t: " $Provider.VDIPort.ToString()
                                            Line 4 "Description`t`t`t: " $Provider.Description
                                            Line 4 "Resource pool`t`t`t: " $Provider.ResourcePool
                                        }                                   }
                                    Line 4 "Dedicated Provider Agent`t: " $DedicatedVDIAgent.ToString()
                                    If($DedicatedVDIAgent)
                                    {
                                            Line 4 "Agent address`t`t`t: " $Provider.VDIAgent
 
                                $cnt = -1 <>  
                                ForEach($line in $ThemePostLogonMessage)    
                                {    
                                        $cnt++    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("Post-logon message:",($Script:htmlsb),$line,$htmlwhite)                                   $columnHeaders = @("Enable provider in site",($Script:htmlsb),$Provider.Enabled.ToString(),$htmlwhite)
                                        }                                   If($VDIType -eq "Azure")
                                        Else    
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))                                           $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))
                                        }                                           $rowdata += @(,("Name",($Script:htmlsb), $Provider.Name,$htmlwhite))
                                }    
     
                                $msg = "Messages"    
                                $columnWidths = @("200","400")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "HTML5 client/URLs"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "HTML5 client/URLs"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                    
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $rowdata += @(,("Description",($Script:htmlsb), $Provider.Description,$htmlwhite))
                                $ScriptInformation.Add(@{Data = "Theme login page:"; Value = $ThemeHTML5URL; }) > $Null                                           $rowdata += @(,("Subscription details",($Script:htmlsb), "",$htmlwhite))
                                $ScriptInformation.Add(@{Data = "Show Parallels Client download URL"; Value = $ThemeShowDownloadURL; }) > $Null                                           $rowdata += @(,("     Authentication URL",($Script:htmlsb), $Provider.VDIAzureCloudInfo.AuthenticationURL,$htmlwhite))
                                $ScriptInformation.Add(@{Data = "Override download URL for branded Parallels Client (Windows)"; Value = $ThemeOverrideDownloadURL; }) > $Null                                           $rowdata += @(,("     Management URL",($Script:htmlsb), $Provider.VDIAzureCloudInfo.ManagementURL,$htmlwhite))
                                            $rowdata += @(,("     Resource URI",($Script:htmlsb), $Provider.VDIAzureCloudInfo.ResourceURI,$htmlwhite))
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $rowdata += @(,("Tenant ID",($Script:htmlsb), $Provider.VDIAzureCloudInfo.TenantID,$htmlwhite))
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                                    
                                If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty    
                                {    
                                        WriteWordLine 4 0 "Footer URLs:"    
                                        [System.Collections.Hashtable[]] $URLWordTable = @();    
                                            
                                        ForEach($FooterURL in $ThemeFooterURLs)    
                                        {    
                                                $URLTableRowHash = @{    
                                                URL     = $FooterURL.URL;    
                                                Text    = $FooterURL.Text;    
                                                Tooltip = $FooterURL.Tooltip;    
                                                }    
                                                $URLWordTable += $URLTableRowHash;    
                                        }    
     
                                        If($URLWordTable.Count -gt 0)    
                                        {    
                                                $Table = AddWordTable -Hashtable $URLWordTable `    
                                                -Columns  URL,Text,Tooltip `    
                                                -Headers  "URL","Text","Tooltip"`    
                                                -Format $wdTableGrid `    
                                                -AutoFit $wdAutoFitFixed;    
     
                                                SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                                $Table.Columns.Item(1).Width = 150;    
                                                $Table.Columns.Item(2).Width = 150;    
                                                $Table.Columns.Item(3).Width = 150;    
     
                                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $rowdata += @(,("Subscription ID",($Script:htmlsb), $Provider.VDIAzureCloudInfo.SubscriptionID,$htmlwhite))
     
                                                FindWordDocumentEnd    
                                                $Table = $Null    
                                                WriteWordLine 0 0 ""    
                                        }    
 
                                        WriteWordLine 0 1 "There are no Footer URLs" <>                                         $rowdata += @(,("Name",($Script:htmlsb), $Provider.Name,$htmlwhite))
                                }                                                 $rowdata += @(,("Description",($Script:htmlsb), $Provider.Description,$htmlwhite))
                        }                                           $rowdata += @(,("Type",($Script:htmlsb),$VDIType,$htmlwhite))
                        If($Text)                                           $rowdata += @(,("Host",($Script:htmlsb),$Provider.Server,$htmlwhite))
                        {                                           $rowdata += @(,("Port",($Script:htmlsb),$Provider.VDIPort.ToString(),$htmlwhite))
                                Line 3 "Theme login page`t`t  : " $ThemeHTML5URL                                           $rowdata += @(,("Description",($Script:htmlsb),$Provider.Description,$htmlwhite))
                                Line 3 "Show Parallels Client download URL: " $ThemeShowDownloadURL                                           $rowdata += @(,("Resource pool",($Script:htmlsb),$Provider.ResourcePool,$htmlwhite))
                                Line 3 "Override download URL for branded "    
                                Line 3 "Parallels Client (Windows)`t  : " $ThemeOverrideDownloadURL    
                                Line 0 ""    
     
                                If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty    
                                {    
                                        Line 3 "Footer URLs:"    
                                        Line 3 "URL                             Text                            Tooltip                       "    
                                        Line 3 "=============================================================================================="    
                                        #       123456789012345678901234567890SS123456789012345678901234567890SS123456789012345678901234567890    
     
                                        ForEach($FooterURL in $ThemeFooterURLs)    
                                        {    
                                                Line 3 ( "{0,-30}  {1,-30}  {2,-30}" -f `    
                                                $FooterURL.URL, $FooterURL.Text, $FooterURL.Tooltip)    
                                        }    
                                            
                                        Line 0 ""    
 
                                Else <>                                 $rowdata += @(,("Dedicated Provider Agent",($Script:htmlsb),$DedicatedVDIAgent.ToString(),$htmlwhite))
                                    If($DedicatedVDIAgent)
 
                                        Line 3 "There are no Footer URLs" <>                                         $rowdata += @(,("Agent address",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite))
                                }                                          }
                        }    
                        If($HTML)    
                        {    
                                $ThemeName = $Theme.Name.Replace("<","").Replace(">","")    
                                $rowdata = @()    
                                $columnHeaders = @("Theme login page:",($Script:htmlsb),$ThemeHTML5URL,$htmlwhite)    
                                $rowdata += @(,("Show Parallels Client download URL",($Script:htmlsb),$ThemeShowDownloadURL,$htmlwhite))    
                                $rowdata += @(,("Override download URL for branded Parallels Client (Windows)",($Script:htmlsb),$ThemeOverrideDownloadURL,$htmlwhite))    
 
                                $msg = "HTML5 client/URLs" <>                                 $msg = "General"
                                $columnWidths = @("200","400")                                   $columnWidths = @("200","275")
 
  <>  
                                If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty    
                                {    
                                        $rowdata = @()    
     
                                        ForEach($FooterURL in $ThemeFooterURLs)    
                                        {    
                                                $rowdata += @(,(    
                                                $FooterURL.URL,$htmlwhite,    
                                                $FooterURL.Text,$htmlwhite,    
                                                $FooterURL.Tooltip,$htmlwhite))    
                                        }                           }
                            
                                        $columnHeaders = @(                           #Credentials
                                        "URL",($Script:htmlsb),    
                                        "Text",($Script:htmlsb),    
                                        "Tooltip",($Script:htmlsb))    
     
                                        $msg = "Footer URLs:"    
                                        $columnWidths = @("150","150","150")    
                                        FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "450"    
                                        WriteHTMLLine 0 0 ""    
                                }    
                                Else    
                                {    
                                        WriteHTMLLine 0 1 "There are no Footer URLs"    
                                }           
                        }    
 
                                WriteWordLine 4 0 "HTML5 client/Branding" <>                                 WriteWordLine 4 0 "Credentials"
 
                                Line 2 "HTML5 client/Branding" <>                                 Line 3 "Credentials"
 
                                $ScriptInformation.Add(@{Data = "Webpage title"; Value = $Theme.HTML5Client.Branding.WebpageTitle; }) > $Null <>                                 If($VDIType -eq "Azure")
                                $ScriptInformation.Add(@{Data = "Login to"; Value = $Theme.HTML5Client.Branding.LoginTo; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Company logo"; Value = $ThemeCompanyLogo; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Favicon icon"; Value = $ThemeFaviconIcon; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Webpage title`t: " $Theme.HTML5Client.Branding.WebpageTitle    
                                Line 3 "Login to`t: " $Theme.HTML5Client.Branding.LoginTo    
                                Line 3 "Company logo`t: " $ThemeCompanyLogo    
                                Line 3 "Favicon icon`t: " $ThemeFaviconIcon    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Webpage title",($Script:htmlsb),$Theme.HTML5Client.Branding.WebpageTitle,$htmlwhite)    
                                $rowdata += @(,("Login to",($Script:htmlsb),$Theme.HTML5Client.Branding.LoginTo,$htmlwhite))    
                                $rowdata += @(,("Company logo",($Script:htmlsb),$ThemeCompanyLogo,$htmlwhite))    
                                $rowdata += @(,("Favicon icon",($Script:htmlsb),$ThemeFaviconIcon,$htmlwhite))    
     
                                $msg = "HTML5 client/Branding"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "HTML5 client/Language bar"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "HTML5 client/Language bar"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Default language"   ; Value = $Theme.HTML5Client.LanguageBar.Default.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "English"            ; Value = $Theme.HTML5Client.LanguageBar.en_US.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "German"             ; Value = $Theme.HTML5Client.LanguageBar.de_DE.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Japanese"           ; Value = $Theme.HTML5Client.LanguageBar.ja_JP.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Russian"            ; Value = $Theme.HTML5Client.LanguageBar.ru_RU.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "French"             ; Value = $Theme.HTML5Client.LanguageBar.fr_FR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Spanish"            ; Value = $Theme.HTML5Client.LanguageBar.es_ES.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Italian"            ; Value = $Theme.HTML5Client.LanguageBar.it_IT.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Portuguese"         ; Value = $Theme.HTML5Client.LanguageBar.pt_BR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Chinese Simplified" ; Value = $Theme.HTML5Client.LanguageBar.zh_CN.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Chinese Traditional"; Value = $Theme.HTML5Client.LanguageBar.zh_TW.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Korean"             ; Value = $Theme.HTML5Client.LanguageBar.ko_KR.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Dutch"              ; Value = $Theme.HTML5Client.LanguageBar.nl_NL.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
                        {    
                                Line 3 "Default language`t: "    $Theme.HTML5Client.LanguageBar.Default.ToString()    
                                Line 3 "English`t`t`t: "         $Theme.HTML5Client.LanguageBar.en_US.ToString()    
                                Line 3 "German`t`t`t: "          $Theme.HTML5Client.LanguageBar.de_DE.ToString()    
                                Line 3 "Japanese`t`t: "          $Theme.HTML5Client.LanguageBar.ja_JP.ToString()    
                                Line 3 "Russian`t`t`t: "         $Theme.HTML5Client.LanguageBar.ru_RU.ToString()    
                                Line 3 "French`t`t`t: "          $Theme.HTML5Client.LanguageBar.fr_FR.ToString()    
                                Line 3 "Spanish`t`t`t: "         $Theme.HTML5Client.LanguageBar.es_ES.ToString()    
                                Line 3 "Italian`t`t`t: "         $Theme.HTML5Client.LanguageBar.it_IT.ToString()    
                                Line 3 "Portuguese`t`t: "        $Theme.HTML5Client.LanguageBar.pt_BR.ToString()    
                                Line 3 "Chinese Simplified`t: "  $Theme.HTML5Client.LanguageBar.zh_CN.ToString()    
                                Line 3 "Chinese Traditional`t: " $Theme.HTML5Client.LanguageBar.zh_TW.ToString()    
                                Line 3 "Korean`t`t`t: "          $Theme.HTML5Client.LanguageBar.ko_KR.ToString()    
                                Line 3 "Dutch`t`t`t: "           $Theme.HTML5Client.LanguageBar.nl_NL.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {    
                                $rowdata = @()    
                                $columnHeaders = @("Default language",($Script:htmlsb),$Theme.HTML5Client.LanguageBar.Default.ToString(),$htmlwhite)    
                                $rowdata += @(,("English"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.en_US.ToString(),$htmlwhite))    
                                $rowdata += @(,("German"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.de_DE.ToString(),$htmlwhite))    
                                $rowdata += @(,("Japanese"           ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ja_JP.ToString(),$htmlwhite))    
                                $rowdata += @(,("Russian"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ru_RU.ToString(),$htmlwhite))    
                                $rowdata += @(,("French"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.fr_FR.ToString(),$htmlwhite))    
                                $rowdata += @(,("Spanish"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.es_ES.ToString(),$htmlwhite))    
                                $rowdata += @(,("Italian"            ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.it_IT.ToString(),$htmlwhite))    
                                $rowdata += @(,("Portuguese"         ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.pt_BR.ToString(),$htmlwhite))    
                                $rowdata += @(,("Chinese Simplified" ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.zh_CN.ToString(),$htmlwhite))    
                                $rowdata += @(,("Chinese Traditional",($Script:htmlsb),$Theme.HTML5Client.LanguageBar.zh_TW.ToString(),$htmlwhite))    
                                $rowdata += @(,("Korean"             ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.ko_KR.ToString(),$htmlwhite))    
                                $rowdata += @(,("Dutch"              ,($Script:htmlsb),$Theme.HTML5Client.LanguageBar.nl_NL.ToString(),$htmlwhite))    
     
                                $msg = "HTML5 client/Language bar"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
     
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "HTML5 client/Messages"    
                        }    
                        If($Text)    
                        {    
                                Line 2 "HTML5 client/Messages"    
                        }    
                        If($HTML)    
                        {    
                                #Nothing    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $cnt = -1    
                                ForEach($line in $ThemeHTML5PrelogonMessage)    
 
                                        $cnt++ <>  
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Pre-logon message:"; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Application ID"; Value = $Provider.VDIUsername; }) > $Null
                                        }                                   }
                                        Else                                   Else
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null    
                                        }    
                                }    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
     
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.HTML5Client.Message.OverridePostLogonMessage.ToString(); }) > $Null    
                                If($Theme.HTML5Client.Message.OverridePostLogonMessage)    
 
                                        ForEach($line in $ThemeHTML5PostlogonMessage) <>  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Username"; Value = $Provider.VDIUsername; }) > $Null
                                        }    
 
                                $cnt = -1 <>                                 If($VDIType -eq "Azure")
                                ForEach($line in $ThemeHTML5PrelogonMessage)    
 
                                        $cnt++ <>  
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Pre-logon message: " $line                                           Line 4 "Application ID: " $Provider.VDIUsername
                                        }                                   }
                                        Else                                   Else
                                        {    
                                                Line 5 "    " $line    
                                        }    
                                }    
                                Line 0 ""    
     
                                Line 3 "Override post-logon message: " $Theme.HTML5Client.Message.OverridePostLogonMessage.ToString()    
                                If($Theme.HTML5Client.Message.OverridePostLogonMessage)    
 
                                        ForEach($line in $ThemeHTML5PostlogonMessage) <>                                         Line 4 "Username`t`t`t: " $Provider.VDIUsername
                                        {    
                                                Line 5 "    " $line    
                                        }    
 
                                $cnt = -1 <>                                 If($VDIType -eq "Azure")
                                ForEach($line in $ThemeHTML5PrelogonMessage)    
 
                                        $cnt++ <>  
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("Pre-logon message:",($Script:htmlsb),$line,$htmlwhite)                                           $columnHeaders = @("Application ID",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite)
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))                                           $columnHeaders = @("Username",($Script:htmlsb),$Provider.VDIUsername,$htmlwhite)
                                        }    
 
                                $msg = "HTML5 client/Messages" <>                                 $msg = "Credentials"
                                $columnWidths = @("200","400")                                   $columnWidths = @("200","275")
 
  <>  
                                $rowdata = @()    
                                $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.HTML5Client.Message.OverridePostLogonMessage.ToString(),$htmlwhite)    
                                If($Theme.HTML5Client.Message.OverridePostLogonMessage)    
                                {    
                                        ForEach($line in $ThemeHTML5PostlogonMessage)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))    
                                        }                           }
                                }    
 
                                $msg = "" <>                         #Agent Settings
                                $columnWidths = @("200","400")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }    
                            
 
                                WriteWordLine 4 0 "HTML5 client/Gateway" <>                                 WriteWordLine 4 0 "Agent settings"
 
                                Line 2 "HTML5 client/Gateway" <>                                 Line 3 "Agent settings"
 
                        If($MSWord -or $PDF) <>                         <#
                            Switch ($Provider.DragAndDropMode)
 
                                $ScriptInformation = New-Object System.Collections.ArrayList <>  
                                $ScriptInformation.Add(@{Data = "Override gateway settings for theme"; Value = $Theme.HTML5Client.Gateway.OverrideGWSettings.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Client"; Value = ""; }) > $Null                                   "Bidirectional"         {$VDIDragAndDrop = "Bidirectional";
                                $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $ThemeHTML5LaunchSessionsUsing; }) > $Null                                   $VDIAllowDragAndDrop = "True";
                                Switch($Theme.HTML5Client.Gateway.LaunchMethod)                                   Break}
                                    "Disabled"                      {$VDIDragAndDrop = "Disabled"; 
                                    $VDIAllowDragAndDrop = "False";
                                    Break}
                                    "ClientToServer"        {$VDIDragAndDrop = "Client to server only"; 
                                    $VDIAllowDragAndDrop = "True";
                                    Break}
                                    "ServerToClient"        {$VDIDragAndDrop = "Server to client only"; 
                                    $VDIAllowDragAndDrop = "True";
                                    Break}
                                    Default                         {$VDIDragAndDrop = "Unable to determine Drag and drop: $($Provider.DragAndDropMode)"; 
                                    $VDIAllowDragAndDrop = "False";
                                    Break}
                            }
                            
                            #>
                            $VDIDragAndDrop = ""
                            $VDIAllowDragAndDrop = ""
     
                            If(validobject $Provider AllowURLAndMailRedirection)
                                {                           {
                                        "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"                                     Switch($Provider.AllowURLAndMailRedirection)
                                        {                                   {
                                            "Enabled"                                               {$VDIAllowClientURLMailRedirection = "Enabled"; 
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                            "Disabled"                                              {$VDIAllowClientURLMailRedirection = "Disabled"; 
                                                                                                             $ReplaceRegisteredApplication = "False";
                                                                                                             Break}
                                            "EnabledWithAppRegistration"    {$VDIAllowClientURLMailRedirection = "Enabled";
                                                                                                             $ReplaceRegisteredApplication = "True";
                                                                                                             Break}
                                                $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString(); }) > $Null                                           Default                                                 {$VDIAllowClientURLMailRedirection = "Unable to determine Allow CLient URL/Mail Redirection: $($Provider.AllowURLAndMailRedirection)";
                                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(); }) > $Null                                                                                                            $ReplaceRegisteredApplication = "False";
                                                Break                                                                                                            Break}
                                        }                                   }
                                        "Launch_Applications_with_Parallels_Client"                                                                        }
                            Else
                                        {                           {
                                                Break                                   $VDIAllowClientURLMailRedirection = ""
                                    $ReplaceRegisteredApplication = "";
                                        }                           }
                                        "Launch_Applications_with_Browser_HTML5"                                                                          
                            If(validobject $Provider FileTransferMode)
                                        {                           {
                                                $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(); }) > $Null                                   Switch ($Provider.FileTransferMode)
                                                Break                                   {
                                            "Bidirectional"         {$ProviderFileTransferMode = "Bidirectional"; Break}
                                            "Disabled"                      {$ProviderFileTransferMode = "Disabled"; Break}
                                            "ClientToServer"        {$ProviderFileTransferMode = "Client to server only"; Break}
                                            "ServerToClient"        {$ProviderFileTransferMode = "Server to client only"; Break}
                                            Default                         {$ProviderFileTransferMode = "Unable to determine File Transfer mode: $($Provider.FileTransferMode)"; Break}
                                        }                                   }
                                }                           }
                                $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $Theme.HTML5Client.Gateway.Pre2000Cred.ToString(); }) > $Null                           Else
                                $ScriptInformation.Add(@{Data = "     Allow embedding of Parallels HTML5 Client into other web pages"; Value = $Theme.HTML5Client.Gateway.AllowEmbed.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $ThemeHTMLFileTransfer; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $ThemeHTMLClipboardDirection; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $Theme.HTML5Client.Gateway.AllowCORS.ToString(); }) > $Null    
                                If($Theme.HTML5Client.Gateway.AllowCORS)    
                                {                           {
                                    $ProviderFileTransferMode = ""
                            }
                                        $cnt=-1    
                                        ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)                           If(validobject $Provider FileTransferLocation)
                                        {                           {
                                                $cnt++                                   If($Provider.FileTransferLocation -eq "")
                                                    
                                                If($cnt -eq 0)    
                                                {                                   {
                                                        $ScriptInformation.Add(@{Data = "Allow domains"; Value = $Domain; }) > $Null                                           $ProviderFileTransferLocation = "Default download location"
                                                }                                   }
                                                Else                                   Else
                                                {                                   {
                                            $ProviderFileTransferLocation = $ProviderHost.FileTransferLocation
                                    }
                            }
                            Else
                            {
                                    $ProviderFileTransferLocation = ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $Provider.VDIAgent; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Allow Client URL/Mail Redirection"; Value = $VDIAllowClientURLMailRedirection; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Replace registered application"; Value = $ReplaceRegisteredApplication; }) > $Null
                                    If(validobject $Provider SupportShellURLNamespaceObjects)
                                    {
                                            $ScriptInformation.Add(@{Data = "     Support Windows Shell URL namespace objects"; Value = $Provider.SupportShellURLNamespaceObjects.ToString(); }) > $Null
                                    }
                                    $ScriptInformation.Add(@{Data = "Enable Drag and drop"; Value = $VDIAllowDragAndDrop; }) > $Null
                                                        $ScriptInformation.Add(@{Data = ""; Value = $Domain; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Direction"; Value = $VDIDragAndDrop; }) > $Null
                                    If(validobject $Provider AllowFileTransfer)
                                    {
                                            $ScriptInformation.Add(@{Data = "Allow file transfer command (Web (HTML5) and Chrome clients)"; Value = $Provider.AllowFileTransfer.ToString(); }) > $Null
                                                }                                   }
                                    $ScriptInformation.Add(@{Data = "     Configure File Transfer"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Direction"; Value = $ProviderFileTransferMode; }) > $Null
                                    $ScriptInformation.Add(@{Data = "          Location"; Value = $ProviderFileTransferLocation; }) > $Null
                                    If(validobject $Provider FileTransferLockLocation)
                                    {
                                            $ScriptInformation.Add(@{Data = "          Do not allow to change location"; Value = $Provider.FileTransferLockLocation.ToString(); }) > $Null
                                        }                                   }
                                    If(validobject $Provider EnableDriveRedirectionCache)
                                    {
                                        $ScriptInformation.Add(@{Data = "Browser cache time"; Value = "$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Enable drive redirection cache"; Value = $Provider.EnableDriveRedirectionCache.ToString(); }) > $Null
 
                                Line 3 "Override gateway settings for theme: " $Theme.HTML5Client.Gateway.OverrideGWSettings.ToString() <>                                 Line 4 "Preferred Connection Broker`t`t`t`t`t: " $Provider.VDIAgent
                                Line 3 "Client"                                   Line 4 "Allow Client URL/Mail Redirection`t`t`t`t: " $VDIAllowClientURLMailRedirection
                                Line 4 "Launch sessions using`t`t`t: " $ThemeHTML5LaunchSessionsUsing                                   Line 5 "Replace registered application`t`t`t`t: " $ReplaceRegisteredApplication
                                Switch($Theme.HTML5Client.Gateway.LaunchMethod)                                   If(validobject $Provider SupportShellURLNamespaceObjects)
 
                                        "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"   <>  
                                        {    
                                                Line 4 "Allow user to select a launch method`t: " $Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString()                                           Line 5 "Support Windows Shell URL namespace objects`t`t: " $Provider.SupportShellURLNamespaceObjects.ToString()
                                                Line 4 "Allow opening applications in a new tab`t: " $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString()    
                                                Break    
                                        }                                   }
                                        "Launch_Applications_with_Parallels_Client"                                                                                Line 4 "Enable Drag and drop`t`t`t`t`t`t: " $VDIAllowDragandDrop
                                        {                                   Line 5 "Direction`t`t`t`t`t`t: " $VDIDragAndDrop
                                                Break                                   If(validobject $Provider AllowFileTransfer)
                                        }    
                                        "Launch_Applications_with_Browser_HTML5"                                                    
                                        {                                   {
                                                Line 4 "Allow opening applications in a new tab`t: " $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString()                                           Line 4 "Allow file transfer command (Web (HTML5) and Chrome clients)`t: " $Provider.AllowFileTransfer.ToString()
                                                Break    
                                        }    
 
                                Line 4 "Use Pre Windows 2000 login format`t: " $Theme.HTML5Client.Gateway.Pre2000Cred.ToString() <>  
                                Line 4 "Allow embedding of Parallels HTML5 "                                   Line 5 "Configure File Transfer"
                                Line 4 "Client into other web pages`t`t: " $Theme.HTML5Client.Gateway.AllowEmbed.ToString()    
                                Line 4 "Allow file transfer command`t`t: " $ThemeHTMLFileTransfer                                   Line 6 "Direction`t`t`t: " $ProviderFileTransferMode
                                Line 4 "Allow clipboard command`t`t`t: " $ThemeHTMLClipboardDirection                                   Line 6 "Location`t`t`t: " $ProviderFileTransferLocation
                                Line 4 "Allow cross-origin resource sharing`t: " $Theme.HTML5Client.Gateway.AllowCORS.ToString()                                   If(validobject $Provider FileTransferLockLocation)
                                If($Theme.HTML5Client.Gateway.AllowCORS)    
 
                                        $cnt=-1 <>  
                                        ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)                                           Line 6 "Do not allow to change location : " $Provider.FileTransferLockLocation.ToString()
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        Line 5 "Allow domains`t`t`t: " $Domain    
                                                }                                   }
                                                Else                                   If(validobject $Provider EnableDriveRedirectionCache)
                                                {                                   {
                                                        Line 9 "  " $Domain    
                                                }    
                                        }    
                                        Line 5 "Browser cache time`t`t: "  "$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months"                                           Line 4 "Enable drive redirection cache`t`t`t`t`t: " $Provider.EnableDriveRedirectionCache.ToString()
 
  <>                                 
 
                                $columnHeaders = @("Override gateway settings for theme",($Script:htmlsb),$Theme.HTML5Client.Gateway.OverrideGWSettings.ToString(),$htmlwhite) <>                                 $columnHeaders = @("Preferred Connection Broker",($Script:htmlsb),$Provider.VDIAgent,$htmlwhite)
                                $rowdata += @(,("Client",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Allow Client URL/Mail Redirection",($Script:htmlsb),$VDIAllowClientURLMailRedirection,$htmlwhite))
                                $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$ThemeHTML5LaunchSessionsUsing,$htmlwhite))                                   $rowdata += @(,("     Replace registered application",($Script:htmlsb),$ReplaceRegisteredApplication,$htmlwhite))
                                Switch($Theme.HTML5Client.Gateway.LaunchMethod)                                   If(validobject $Provider SupportShellURLNamespaceObjects)
 
                                        "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"   <>  
                                        {    
                                                $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$Theme.HTML5Client.Gateway.AllowLaunchMethod.ToString(),$htmlwhite))                                           $rowdata += @(,("     Support Windows Shell URL namespace objects",($Script:htmlsb),$Provider.SupportShellURLNamespaceObjects.ToString(),$htmlwhite))
                                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))    
                                                Break    
                                        }                                   }
                                        "Launch_Applications_with_Parallels_Client"                                                                                $rowdata += @(,("Enable Drag and drop",($Script:htmlsb),$VDIAllowDragAndDrop,$htmlwhite))
                                        {                                   $rowdata += @(,("     Directon",($Script:htmlsb),$VDIDragAndDrop,$htmlwhite))
                                                Break                                   If(validobject $Provider AllowFileTransfer)
                                        }    
                                        "Launch_Applications_with_Browser_HTML5"                                                    
                                        {                                   {
                                                $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))                                           $rowdata += @(,("Allow file transfer command (Web (HTML5) and Chrome clients)",($Script:htmlsb),$Provider.AllowFileTransfer.ToString(),$htmlwhite))
                                                Break    
                                        }    
 
                                $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb), $Theme.HTML5Client.Gateway.Pre2000Cred.ToString(),$htmlwhite)) <>  
                                $rowdata += @(,("     Allow embedding of Parallels HTML5 Client into other web pages",($Script:htmlsb), $Theme.HTML5Client.Gateway.AllowEmbed.ToString(),$htmlwhite))    
                                $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$ThemeHTMLFileTransfer,$htmlwhite))                                   $rowdata += @(,("     Configure File Transfer",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$ThemeHTMLClipboardDirection,$htmlwhite))                                   $rowdata += @(,("          Direction",($Script:htmlsb),$ProviderFileTransferMode,$htmlwhite))
                                $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$Theme.HTML5Client.Gateway.AllowCORS.ToString(),$htmlwhite))                                   $rowdata += @(,("          Location",($Script:htmlsb),$ProviderFileTransferLocation,$htmlwhite))
                                If($Theme.HTML5Client.Gateway.AllowCORS)                                   If(validobject $Provider FileTransferLockLocation)
 
                                        $cnt=-1 <>  
                                        ForEach($Domain in $Theme.HTML5Client.Gateway.AllowedDomainsForCORS)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Allow domains",($Script:htmlsb),$Domain,$htmlwhite))                                           $rowdata += @(,("          Do not allow to change location",($Script:htmlsb),$Provider.FileTransferLockLocation.ToString(),$htmlwhite))
                                                }                                   }
                                                Else                                   If(validobject $Provider EnableDriveRedirectionCache)
                                                {                                   {
                                                        $rowdata += @(,("",($Script:htmlsb),$Domain,$htmlwhite))    
                                                }    
                                        }    
                                        $rowdata += @(,("Browser cache time",($Script:htmlsb),"$($Theme.HTML5Client.Gateway.BrowserCacheTimeInMonths.ToString()) months",$htmlwhite))                                           $rowdata += @(,("Enable drive redirection cache",($Script:htmlsb),$Provider.EnableDriveRedirectionCache.ToString(),$htmlwhite))
 
  -+                                 
 
                                $msg = "HTML5 client/Gateway" <>                                 $msg = "Agent settings"
                                $columnWidths = @("300","300")                                   $columnWidths = @("200","275")
 
  -+                         #RDP Printer
                            
 
                                WriteWordLine 4 0 "HTML5 client/Legal policies" <>                                 WriteWordLine 4 0 "RDP printer"
 
                                Line 2 "HTML5 client/Legal policies" <>                                 Line 3 "RDP printer"
 
                        If($MSWord -or $PDF) <>  
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList                           If(validobject $Provider PrinterNameFormat)
                                $ScriptInformation.Add(@{Data = "Cookie consent"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Enable cookie consent"; Value = $Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "End User License Agreement"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Enable EULA"; Value = $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString(); }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }    
                        If($Text)    
 
                                Line 3 "Cookie consent"  <>                                 Switch ($Provider.PrinterNameFormat)
                                Line 4 "Enable cookie consent`t: " $Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString()    
                                Line 3 "End User License Agreement"     
                                Line 4 "Enable EULA`t`t: " $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString()    
                                Line 0 ""    
                        }    
                        If($HTML)    
                        {                                   {
                                $rowdata = @()                                           "PrnFormat_PRN_CMP_SES" {$ProviderPrinterNameFormat = "Printername (from Computername) in Session no."; Break}
                                $columnHeaders = @("Cookie consent",($Script:htmlsb),"",$htmlwhite)                                           "PrnFormat_SES_CMP_PRN" {$ProviderPrinterNameFormat = "Session no. (Computername from) Printername"; Break}
                                $rowdata += @(,("     Enable cookie consent",($Script:htmlsb),$Theme.HTML5Client.LegalPolicies.AllowCookieConsent.ToString(),$htmlwhite))                                           "PrnFormat_PRN_REDSES"  {$ProviderPrinterNameFormat = "Printername (redirected Session no.)"; Break}
                                $rowdata += @(,("End User License Agreement",($Script:htmlsb),"",$htmlwhite))                                           Default                                 {$ProviderPrinterNameFormat = "Unable to determine RDP Printer Name Format: $($Provider.PrinterNameFormat)"; Break}
                                $rowdata += @(,("     Enable EULA",($Script:htmlsb), $Theme.HTML5Client.LegalPolicies.AllowEULA.ToString(),$htmlwhite))    
     
                                $msg = "HTML5 client/Legal policies"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                        }                                   }
     
                        If($MSWord -or $PDF)    
                        {    
                                WriteWordLine 4 0 "Windows client/Branding"    
 
                        If($Text) <>  
                        {                           Else
                                Line 2 "Windows client/Branding"    
                        }    
                        If($HTML)    
 
                                #Nothing <>                                 $ProviderPrinterNameFormat = ""
 
                        If($MSWord -or $PDF) <>                         If(validobject $Provider RemoveSessionNumberFromPrinterName)
 
                                $ScriptInformation = New-Object System.Collections.ArrayList <>                                 $ProviderRemoveSessionNumberFromPrinter = $Provider.RemoveSessionNumberFromPrinterName.ToString()
                                $ScriptInformation.Add(@{Data = "Company name"; Value = $Theme.WindowsClient.Branding.CompanyName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Application name"; Value = $Theme.WindowsClient.Branding.ApplicationName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Connection banner"; Value = $ThemeConnectionBanner; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Application icon"; Value = $ThemeApplicationIcon; }) > $Null    
     
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
     
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
 
                        If($Text) <>  
                        {                           Else
                                Line 3 "Company name`t`t: " $Theme.WindowsClient.Branding.CompanyName    
                                Line 3 "Application name`t: " $Theme.WindowsClient.Branding.ApplicationName    
                                Line 3 "Connection banner`t: " $ThemeConnectionBanner    
                                Line 3 "Application icon`t: " $ThemeApplicationIcon    
                                Line 0 ""    
                        }    
                        If($HTML)    
 
                                $rowdata = @() <>                                 $ProviderRemoveSessionNumberFromPrinter = ""
                                $columnHeaders = @("Company name",($Script:htmlsb),$Theme.WindowsClient.Branding.CompanyName,$htmlwhite)    
                                $rowdata += @(,("Application name",($Script:htmlsb),$Theme.WindowsClient.Branding.ApplicationName,$htmlwhite))    
                                $rowdata += @(,("Connection banner",($Script:htmlsb),$ThemeConnectionBanner,$htmlwhite))    
                                $rowdata += @(,("Application icon",($Script:htmlsb),$ThemeApplicationIcon,$htmlwhite))    
     
                                $msg = "Windows client/Branding"    
                                $columnWidths = @("200","275")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
 
                        If($MSWord -or $PDF) <>                         If(validobject $Provider RemoveClientNameFromPrinterName)
 
                                WriteWordLine 4 0 "Windows client/Messages" <>                                 $ProviderRemoveClientNameFromPrinter = $Provider.RemoveClientNameFromPrinterName.ToString()
 
                        If($Text) <>  
                        {                           Else
                                Line 2 "Windows client/Messages"    
                        }    
                        If($HTML)    
 
                                #Nothing <>                                 $ProviderRemoveClientNameFromPrinter = ""
 
                         <>  
 
  <>                                 $ScriptInformation.Add(@{Data = "RDP Printer Name Format"; Value = $ProviderPrinterNameFormat; }) > $Null
                                $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Remove session number from printer name"; Value = $ProviderRemoveSessionNumberFromPrinter; }) > $Null
                                If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)                                   If($Provider.RemoveSessionNumberFromPrinterName)
 
                                        ForEach($line in $ThemeWindowsPostlogonMessage) <>  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null                                           $ScriptInformation.Add(@{Data = "Remove client name from printer name"; Value = $ProviderRemoveClientNameFromPrinter; }) > $Null
                                        }    
 
                                Line 3 "Override post-logon message: " $Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString() <>                                 Line 4 "RDP Printer Name Format`t`t`t`t: " $ProviderPrinterNameFormat
                                If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)                                   Line 4 "Remove session number from printer name`t`t: " $ProviderRemoveSessionNumberFromPrinter
                                    If($Provider.RemoveSessionNumberFromPrinterName)
 
                                        ForEach($line in $ThemeWindowsPostlogonMessage) <>                                         Line 4 "Remove client name from printer name`t`t`t: " $ProviderRemoveClientNameFromPrinter
                                        {    
                                                Line 5 "    " $line    
                                        }    
 
  <>                                 $columnHeaders = @("RDP Printer Name Format",($Script:htmlsb),$ProviderPrinterNameFormat,$htmlwhite)
                                $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString(),$htmlwhite)                                   $rowdata += @(,("Remove session number from printer name",($Script:htmlsb),$ProviderRemoveSessionNumberFromPrinter,$htmlwhite))
                                If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)                                   If($Provider.RemoveSessionNumberFromPrinterName)
 
                                        ForEach($line in $ThemeWindowsPostlogonMessage) <>                                         $rowdata += @(,("Remove client name from printer name",($Script:htmlsb),$ProviderRemoveClientNameFromPrinter,$htmlwhite))
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))    
                                        }    
 
                                $msg = "Windows client/Messages" <>                                 $msg = "RDP printer"
                                $columnWidths = @("200","400")                                   $columnWidths = @("200","275")
 
  <>                 }
            }
            
            #Remote PCs are not in PoSH
            
            Write-Verbose "$(Get-Date -Format G): `tOutput Secure Gateways"
                        If($MSWord -or $PDF)           If($MSWord -or $PDF)
                        {           {
                                WriteWordLine 4 0 "Windows client/Custom menu"                   WriteWordLine 2 0 "Secure Gateways"
                        }           }
                        If($Text)           If($Text)
                        {           {
                                Line 2 "Windows client/Custom menu"                   Line 1 "Secure Gateways"
                        }           }
                        If($HTML)           If($HTML)
                        {           {
                    WriteHTMLLine 2 0 "Secure Gateways"
            }
     
            $SecureGateways = Get-RASGateway -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                                #Nothing                   `n
                    Unable to retrieve Secure Gateways for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
                        }                   }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Secure Gateways for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $SecureGateways)
            {
                    Write-Host "
                    No Secure Gateways retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Secure Gateways retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Secure Gateways retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Secure Gateways"
                    ForEach($SecureGateway in $SecureGateways)
                    {
                            $SecureGatewayStatus = Get-RASGatewayStatus -Id $SecureGateway.Id -EA 0 4>$Null
 
  <>                         If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve Secure Gateway Status for Gateway $($SecureGateway.Id)`
                                    "
                        If($MSWord -or $PDF)                                   If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve Secure Gateway Status for Gateway $($SecureGateway.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve Secure Gateway Status for Gateway $($SecureGateway.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve Secure Gateway Status for Gateway $($SecureGateway.Id)"
                                    }
                                    #unable to retrieve
                                    $SecureGatewayEnableHSTS            = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayEnableSSL             = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayEnableSSLOnPort       = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayAcceptedSSLVersions   = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayCipherStrength        = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayCipher                = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayCertificates          = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayHSTSMaxage            = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayHSTSIncludeSubdomains = "Unable to retrieve Secure Gateway Status"
                                    $SecureGatewayHSTSPreload           = "Unable to retrieve Secure Gateway Status"
                            }
                            ElseIf($? -and $Null -eq $SecureGatewayStatus)
 
  <>                                 Write-Host "
                                    No Secure Gateway Status retrieved for Secure Gateway $($SecureGateway.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No Secure Gateway Status found for Secure Gateway $($SecureGateway.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No Secure Gateway Status found for Secure Gateway $($SecureGateway.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No Secure Gateway Status found for Secure Gateway $($SecureGateway.Id)"
                                    }
                                    #set all to blank
                                    $SecureGatewayEnableHSTS            = ""
                                    $SecureGatewayEnableSSL             = ""
                                    $SecureGatewayEnableSSLOnPort       = ""
                                    $SecureGatewayAcceptedSSLVersions   = ""
                                    $SecureGatewayCipherStrength        = ""
                                    $SecureGatewayCipher                = ""
                                    $SecureGatewayCertificates          = ""
                                    $SecureGatewayHSTSMaxage            = ""
                                    $SecureGatewayHSTSIncludeSubdomains = ""
                                    $SecureGatewayHSTSPreload           = ""
                            }
                            Else
                            {
                                    If($SecureGateway.InheritDefaultSslTlsSettings)
                                    {
                                            #do we inherit site defaults?
                                            #yes we do, get the default settings for the Site
                                            #use the Site default settings
     
                                            $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                            
                                            If($? -and $Null -ne $SecureGatewayDefaults)
                                            {
                                                    If($SecureGatewayDefaults.EnableHSTS)
                                                    {
                                                            $SecureGatewayEnableHSTS            = $SecureGatewayDefaults.EnableHSTS.ToString()
                                                            $SecureGatewayHSTSMaxage            = $SecureGatewayDefaults.HSTSMaxAge.ToString()
                                                            $SecureGatewayHSTSIncludeSubdomains = $SecureGatewayDefaults.HSTSIncludeSubdomains.ToString()
                                                            $SecureGatewayHSTSPreload           = $SecureGatewayDefaults.HSTSPreload.ToString()
                                                    }
                                                    Else
                                                    {
                                                            $SecureGatewayEnableHSTS = $SecureGatewayDefaults.EnableHSTS.ToString()
                                                    }
                                                    $SecureGatewayEnableSSL       = $SecureGatewayDefaults.EnableSSL.ToString()
                                                    $SecureGatewayEnableSSLOnPort = $SecureGatewayDefaults.SSLPort.ToString()
                                                    
                                                    Switch ($SecureGatewayDefaults.MinSSLVersion)
                                                    {
                                                            "SSLv2"         {$SecureGatewayAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                                            "SSLv3"         {$SecureGatewayAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                                            "TLSv1"         {$SecureGatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}
                                                            "TLSv1_1"       {$SecureGatewayAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                                            "TLSv1_2"       {$SecureGatewayAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                                            Default         {$SecureGatewayAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($SecureGatewayDefaults.MinSSLVersion)"; Break}
                                                    }
                                                    
                                                    $SecureGatewayCipherStrength = $SecureGatewayDefaults.CipherStrength.ToString()
                                                    $SecureGatewayCipher         = $SecureGatewayDefaults.Cipher
                                                    
                                                    If($SecureGatewayDefaults.CertificateId -eq 0)
                                                    {
                                                            $SecureGatewayCertificates = "All matching usage"
                                                    }
                                                    Else
                                                    {
                                                            $Results = Get-RASCertificate -Id $SecureGatewayDefaults.CertificateId -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $Results)
                                                            {
                                                                    $SecureGatewayCertificates = $Results.Name
                                                            }
                                                            Else
                                                            {
                                                                    $SecureGatewayCertificates = "Unable to determin Gateway Certificate: $($SecureGatewayDefaults.CertificateId)"
                                                            }
                                                    }
                                            }
                                            Else
                                            {
                                                    #unable to retrieve default, use built-in default values
                                                    $SecureGatewayEnableHSTS          = "False"
                                                    $SecureGatewayEnableSSL           = "True"
                                                    $SecureGatewayEnableSSLOnPort     = "443"
                                                    $SecureGatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"
                                                    $SecureGatewayCipherStrength      = "High"
                                                    $SecureGatewayCipher              = "EECDH:!SSLv2:!SSLv3:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"
                                                    $SecureGatewayCertificates        = "All matching usage"
                                            }
                                    }
                                    Else
                                    {
                                            #we don't inherit settings
                                            #get the settings configured for this GW
                                            If($SecureGateway.EnableHSTS)
                                            {
                                                    $SecureGatewayEnableHSTS            = $SecureGateway.EnableHSTS.ToString()
                                                    $SecureGatewayHSTSMaxage            = $SecureGateway.HSTSMaxAge.ToString()
                                                    $SecureGatewayHSTSIncludeSubdomains = $SecureGateway.HSTSIncludeSubdomains.ToString()
                                                    $SecureGatewayHSTSPreload           = $SecureGateway.HSTSPreload.ToString()
                                            }
                                            Else
                                            {
                                                    $SecureGatewayEnableHSTS = $SecureGateway.EnableHSTS.ToString()
                                            }
                                            $SecureGatewayEnableSSL       = $SecureGateway.EnableSSL.ToString()
                                            $SecureGatewayEnableSSLOnPort = $SecureGateway.SSLPort.ToString()
                                            
                                            Switch ($SecureGateway.MinSSLVersion)
                                            {
                                                    "SSLv2"         {$SecureGatewayAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                                    "SSLv3"         {$SecureGatewayAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                                    "TLSv1"         {$SecureGatewayAcceptedSSLVersions = "TLS v1 - TLS v1.2"; Break}
                                                    "TLSv1_1"       {$SecureGatewayAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                                    "TLSv1_2"       {$SecureGatewayAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                                    Default         {$SecureGatewayAcceptedSSLVersions = "Unable to determine Minimum SSL Version: $($SecureGateway.MinSSLVersion)"; Break}
                                            }
                                            
                                            $SecureGatewayCipherStrength = $SecureGateway.CipherStrength.ToString()
                                            $SecureGatewayCipher         = $SecureGateway.Cipher
                                            
                                            If($SecureGateway.CertificateId -eq 0)
                                            {
                                                    $SecureGatewayCertificates = "All matching usage"
                                            }
                                            Else
                                            {
                                                    $Results = Get-RASCertificate -Id $SecureGateway.CertificateId -EA 0 4>$Null
                                                    
                                                    If($? -and $Null -ne $Results)
                                                    {
                                                            #double replace to remove the < and > from the cert name so it doesn't mess up HTML output
                                                            $SecureGatewayCertificates = $Results.Name.Replace("<","").Replace(">","")      
                                                    }
                                                    Else
                                                    {
                                                            $SecureGatewayCertificates = "Unable to determine Gateway Certificate: $($SecureGateway.CertificateId)"
                                                    }
                                            }
                                    }
                                    
                                    $SecureGatewayStatusAgentState = GetRASStatus $SecureGatewayStatus.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Secure Gateway $($SecureGateway.Server)"
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Server"; Value = $SecureGateway.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "Menu item"; Value = $Theme.WindowsClient.CustomMenu.MenuItem; }) > $Null                                           $ScriptInformation.Add(@{Data = "Mode"; Value = $SecureGateway.Mode; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $SecureGatewayStatusAgentState; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Description"; Value = $SecureGateway.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Certificate"; Value = $SecureGatewayCertificates; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Log level"; Value = $SecureGatewayStatus.LogLevel; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $SecureGateway.AdminLastMod; }) > $Null
                                $ScriptInformation.Add(@{Data = "Command"; Value = $Theme.WindowsClient.CustomMenu.Command; }) > $Null                                           $ScriptInformation.Add(@{Data = "Modified on"; Value = $SecureGateway.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $SecureGateway.AdminCreate.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $SecureGateway.TimeCreate.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "ID"; Value = $SecureGateway.Id.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 250;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Menu item: " $Theme.WindowsClient.CustomMenu.MenuItem                                           Line 2 "Secure Gateway $($SecureGateway.Server)"
                                            Line 3 "Server`t`t`t: " $SecureGateway.Server
                                            Line 3 "Mode`t`t`t: " $SecureGateway.Mode
                                            Line 3 "Status`t`t`t: " $SecureGatewayStatusAgentState
                                            Line 3 "Description`t`t: " $SecureGateway.Description
                                            Line 3 "Certificate`t`t: " $SecureGatewayCertificates
                                            Line 3 "Log level`t`t: " $SecureGatewayStatus.LogLevel
                                            Line 3 "Last modification by`t: " $SecureGateway.AdminLastMod
                                Line 3 "Command`t : " $Theme.WindowsClient.CustomMenu.Command                                           Line 3 "Modified on`t`t: " $SecureGateway.TimeLastMod.ToString()
                                            Line 3 "Created by`t`t: " $SecureGateway.AdminCreate.ToString()
                                            Line 3 "Created on`t`t: " $SecureGateway.TimeCreate.ToString()
                                            Line 3 "ID`t`t`t: " $SecureGateway.Id.ToString()
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                            WriteHTMLLine 3 0 "Secure Gateway $($SecureGateway.Server)"
                                $rowdata = @()                                           $rowdata = @()
                                $columnHeaders = @("Menu item",($Script:htmlsb),$Theme.WindowsClient.CustomMenu.MenuItem,$htmlwhite)                                           $columnHeaders = @("Server",($Script:htmlsb),$SecureGateway.Server,$htmlwhite)
                                $rowdata += @(,("Command",($Script:htmlsb),$Theme.WindowsClient.CustomMenu.Command,$htmlwhite))                                           $rowdata += @(,("Mode",($Script:htmlsb),$SecureGateway.Mode.ToString(),$htmlwhite))
                                            $rowdata += @(,("Status",($Script:htmlsb),$SecureGatewayStatusAgentState.ToString(),$htmlwhite))
                                            $rowdata += @(,("Description",($Script:htmlsb),$SecureGateway.Description,$htmlwhite))
                                            $rowdata += @(,("Certificate",($Script:htmlsb),$SecureGatewayCertificates,$htmlwhite))
                                            $rowdata += @(,("Log level",($Script:htmlsb),$SecureGatewayStatus.LogLevel,$htmlwhite))
                                            $rowdata += @(,("Last modification by",($Script:htmlsb), $SecureGateway.AdminLastMod,$htmlwhite))
                                            $rowdata += @(,("Modified on",($Script:htmlsb), $SecureGateway.TimeLastMod.ToString(),$htmlwhite))
                                            $rowdata += @(,("Created by",($Script:htmlsb), $SecureGateway.AdminCreate.ToString(),$htmlwhite))
                                            $rowdata += @(,("Created on",($Script:htmlsb), $SecureGateway.TimeCreate.ToString(),$htmlwhite))
                                            $rowdata += @(,("ID",($Script:htmlsb),$SecureGateway.Id.ToString(),$htmlwhite))
 
                                $msg = "Windows client/Custom menu" <>                                         $msg = ""
                                $columnWidths = @("200","275")                                           $columnWidths = @("300","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
                        }                                   }
                }                           }
        }    
     
        #Certificates    
     
        $Certs = Get-RASCertificate -Siteid $Site.Id -EA 0 4> $Null    
                                  
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Certificates for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                   WriteWordLine 4 0 "General"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                   Line 2 "General"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                   #Nothing
                }                           }
        }                           
        ElseIf($? -and $Null -eq $Certs)                           Switch ($SecureGateway.IPVersion)
        {                           {
                Write-Host "                                   "Version4"              {$IPVersion = "Version 4"; Break}
                No Certificates retrieved for Site $($Site.Name).`                                   "Version6"              {$IPVersion = "Version 6"; Break}
                " -ForegroundColor White                                   "BothVersions"  {$IPVersion = "Both version 4 & 6"; Break}
                If($MSWord -or $PDF)                                   Default                 {$IPVersion = "Unable to determine IP version: $($SecureGateway.IPVersion)"; Break}
                            }
                            
                            $SecureGatewayIPs = $SecureGateway.IPs.Split(";")
                            
                            If($SecureGateway.BindV4Addresses -eq "")
                {                           {
                        WriteWordLine 0 0 "No Certificates retrieved for Site $($Site.Name)"                                   $SecureGatewayBindV4Addresses = "All available addresses"
                }                           }
                If($Text)                           Else
                {                           {
                        Line 0 "No Certificates retrieved for Site $($Site.Name)"                                   $SecureGatewayBindV4Addresses = $SecureGateway.BindV4Addresses
                }                           }
                If($HTML)    
                            If($SecureGateway.OptimizeConnectionIPv4 -eq "<All>")
                {                           {
                        WriteHTMLLine 0 0 "No Certificates retrieved for Site $($Site.Name)"                                   $SecureGatewayOptimizeV4 = "All available addresses"
                }                           }
                            ElseIf($SecureGateway.OptimizeConnectionIPv4 -eq "<None>")
                            {
                                    $SecureGatewayOptimizeV4 = "None from the available"
        }                           }
        Else                           Else
        {                           {
                If($MSWord -or $PDF)                                   $SecureGatewayOptimizeV4 = $SecureGateway.OptimizeConnectionIPv4
                            }
     
                            If($SecureGateway.BindV6Addresses -eq "")
                {                           {
                        WriteWordLine 2 0 "Certificates"                                   $SecureGatewayBindV6Addresses = "All available addresses"
                }                           }
                If($Text)                           Else
                {                           {
                        Line 1 "Certificates"                                   $SecureGatewayBindV6Addresses = $SecureGateway.BindV6Addresses
                }                           }
                If($HTML)    
                            If($SecureGateway.OptimizeConnectionIPv6 -eq "<All>")
                {                           {
                        WriteHTMLLine 2 0 "Certificates"                                   $SecureGatewayOptimizeV6 = "All available addresses"
                }                           }
                            ElseIf($SecureGateway.OptimizeConnectionIPv6 -eq "<None>")
                            {
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Certificates"                                   $SecureGatewayOptimizeV6 = "None from the available"
                ForEach($Cert in $Certs)                           }
                            Else
                {                           {
                                    $SecureGatewayOptimizeV6 = $SecureGateway.OptimizeConnectionIPv6
                            }
     
 
                                WriteWordLine 3 0 "Certificate $($Cert.Name)" +-  
 
                                $ScriptInformation.Add(@{Data = "Name"; Value = $Cert.Name; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Enable Secure Gateway in Site"; Value = $SecureGateway.Enabled.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Status"; Value = $Cert.Status.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Server"; Value = $SecureGateway.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "Expiration date"; Value = $Cert.ExpirationDate; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $SecureGateway.Description; }) > $Null
                                $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null                                   $ScriptInformation.Add(@{Data = "IP version"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "Common name"; Value = $Cert.CommonName; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $IPVersion; }) > $Null
 
                                $cnt=-1 <>                                 $cnt = -1
                                ForEach($Item in $Cert.AlternateNames)                                   ForEach($Item in $SecureGatewayIPs)
 
                                         <>  
                                        If($cnt -eq 0)                                           If($cnt -eq 0 )
 
                                                $ScriptInformation.Add(@{Data = "Alternate Names"; Value = $Item; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "     IP(s)"; Value = $Item; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Cert.AdminLastMod; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Bind to IP"; Value = ""; }) > $Null
                                    If($SecureGateway.IPVersion -ne "Version6")
                                    {
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $Cert.TimeLastMod.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     Bind to the following IPv4"; Value = $SecureGatewayBindV4Addresses; }) > $Null
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $Cert.AdminCreate; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $SecureGatewayOptimizeV4; }) > $Null
                                    }
                                    If($SecureGateway.IPVersion -ne "Version4")
                                    {
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $Cert.TimeCreate.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     Bind to the following IPv6"; Value = $SecureGatewayBindV6Addresses; }) > $Null
                                $ScriptInformation.Add(@{Data = "ID"; Value = $Cert.Id.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "     Remove system buffers for"; Value = $SecureGatewayOptimizeV6; }) > $Null
                                    }
 
                                Line 2 "Certificate $($Cert.Name)" <>                                 Line 3 "Enable Secure Gateway in Site: " $SecureGateway.Enabled.ToString()
                                Line 3 "Name`t`t`t: " $Cert.Name                                   Line 3 "Server`t`t`t`t`t: " $SecureGateway.Server
                                Line 3 "Status`t`t`t: " $Cert.Status.ToString()    
                                Line 3 "Expiration date`t`t: " $Cert.ExpirationDate                                   Line 3 "Description`t`t`t`t: " $SecureGateway.Description
                                    Line 3 "IP version" ""
                                Line 3 "Usage`t`t`t: " $Cert.Usage                                   Line 4 "Use IP version`t`t`t: " $IPVersion
                                Line 3 "Common name`t`t: " $Cert.CommonName    
 
                                $cnt=-1 <>                                 $cnt = -1
                                ForEach($Item in $Cert.AlternateNames)                                   ForEach($Item in $SecureGatewayIPs)
 
                                         <>  
                                        If($cnt -eq 0)                                           If($cnt -eq 0 )
 
                                                Line 3 "Alternate Names`t`t: " $Item <>                                                 Line 4 "IP(s)`t`t`t`t: " $Item
 
                                                Line 6 "  " $Item <>                                                 Line 8 "  " $Item
 
  <>                                 Line 3 "Bind to IP" ""
                                    If($SecureGateway.IPVersion -ne "Version6")
                                    {
                                Line 3 "Last modification by`t: " $Cert.AdminLastMod                                           Line 4 "Bind to the following IPv4`t: " $SecureGatewayBindV4Addresses
                                            Line 4 "Remove system buffers for`t: " $SecureGatewayOptimizeV4
                                    }
                                    If($SecureGateway.IPVersion -ne "Version4")
                                    {
                                Line 3 "Modified on`t`t: " $Cert.TimeLastMod.ToString()                                           Line 4 "Bind to the following IPv6`t: " $SecureGatewayBindV6Addresses
                                Line 3 "Created by`t`t: " $Cert.AdminCreate                                           Line 4 "Remove system buffers for`t: " $SecureGatewayOptimizeV6
                                Line 3 "Created on`t`t: " $Cert.TimeCreate.ToString()                                   }
                                Line 3 "ID`t`t`t: " $Cert.Id.ToString()    
 
                                $CertName = $Cert.Name.Replace("<","").Replace(">","") +-  
                                WriteHTMLLine 3 0 "Certificate $CertName"    
 
                                $columnHeaders = @("Name",($Script:htmlsb),$CertName,$htmlwhite) <>                                 $columnHeaders = @("Enable Secure Gateway in Site",($Script:htmlsb),$SecureGateway.Enabled.ToString(),$htmlwhite)
                                $rowdata += @(,("Status",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))                                   $rowdata += @(,("Server",($Script:htmlsb),$SecureGateway.Server,$htmlwhite))
                                $rowdata += @(,("Expiration date",($Script:htmlsb),$Cert.ExpirationDate,$htmlwhite))                                   $rowdata += @(,("Description",($Script:htmlsb),$SecureGateway.Description,$htmlwhite))
                                $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))                                   $rowdata += @(,("IP version",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("Common name",($Script:htmlsb),$Cert.CommonName,$htmlwhite))                                   $rowdata += @(,("     Use IP version",($Script:htmlsb),$IPVersion,$htmlwhite))
 
                                $cnt=-1 <>                                 $cnt = -1
                                ForEach($Item in $Cert.AlternateNames)                                   ForEach($Item in $SecureGatewayIPs)
 
                                         <>  
                                        If($cnt -eq 0)                                           If($cnt -eq 0 )
 
                                                $rowdata += @(,("Alternate Names",($Script:htmlsb),$Item,$htmlwhite)) <>                                                 $rowdata += @(,("     IP(s)",($Script:htmlsb),$Item,$htmlwhite))
 
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $Cert.AdminLastMod,$htmlwhite)) <>                                 $rowdata += @(,("Bind to IP",($Script:htmlsb),"",$htmlwhite))
                                    If($SecureGateway.IPVersion -ne "Version6")
                                    {
                                $rowdata += @(,("Modified on",($Script:htmlsb), $Cert.TimeLastMod.ToString(),$htmlwhite))                                           $rowdata += @(,("     Bind to the following IPv4",($Script:htmlsb),$SecureGatewayBindV4Addresses,$htmlwhite))
                                $rowdata += @(,("Created by",($Script:htmlsb), $Cert.AdminCreate,$htmlwhite))                                           $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$SecureGatewayOptimizeV4,$htmlwhite))
                                    }
                                    If($SecureGateway.IPVersion -ne "Version4")
                                    {
                                $rowdata += @(,("Created on",($Script:htmlsb), $Cert.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("     Bind to the following IPv6",($Script:htmlsb),$SecureGatewayBindV6Addresses,$htmlwhite))
                                $rowdata += @(,("ID",($Script:htmlsb),$Cert.Id.ToString(),$htmlwhite))                                           $rowdata += @(,("     Remove system buffers for",($Script:htmlsb),$SecureGatewayOptimizeV6,$htmlwhite))
                                    }
 
                                $msg = "" <>                                 $msg = "General"
                                $columnWidths = @("200","275")                                   $columnWidths = @("300","275")
 
  -+                         #Mode
                            
 
                                WriteWordLine 4 0 "General" <>                                 WriteWordLine 4 0 "Mode"
 
                                Line 2 "General" <>                                 Line 2 "Mode"
 
                        Switch($Cert.KeySize) <>                         If($SecureGateway.InheritDefaultModeSettings)
 
                                "KeySize1024"           {$KeySize = "1024"; Break} <>                                 #do we inherit site defaults?
                                "KeySize2048"           {$KeySize = "2048"; Break}                                   #yes we do, get the default settings for the Site
                                "KeySize4096"           {$KeySize = "4096"; Break}                                   #use the Site default settings
                                "KeySizeUnknown"        {$KeySize = ""; Break}    
                                Default                         {$KeySize = "Unable to determine certificate key size: $($Cert.KeySize)"; Break}    
                        }    
                            
                        If($MSWord -or $PDF)    
                        {    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $Cert.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $Cert.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null    
                                $ScriptInformation.Add(@{Data = "State"; Value = $Cert.Status.ToString(); }) > $Null                                   $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                $ScriptInformation.Add(@{Data = "Key size"; Value = $KeySize; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Expiration date"; Value = $Cert.ExpirationDate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Common name"; Value = $Cert.CommonName; }) > $Null    
 
                                $cnt=-1 <>                                 If($? -and $Null -ne $SecureGatewayDefaults)
                                ForEach($Item in $Cert.AlternateNames)    
 
                                        $cnt++ <>                                         $SecureGatewayMode = $SecureGatewayDefaults.Mode.ToString()
                                                                                  $SecureGatewayForwardRequests = $SecureGatewayDefaults.NormalModeForwarding.ToString()
                                        If($cnt -eq 0)                                           If($SecureGatewayMode -eq "Normal")
 
                                                $ScriptInformation.Add(@{Data = "Alternate Names"; Value = $Item; }) > $Null <>                                                 $SecureGatewayServers = $SecureGatewayDefaults.ForwardHttpServers.Split(";")
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null <>                                                 $SecureGatewayServers = $SecureGatewayDefaults.ForwardGatewayServers.Split(";")
 
                                } +-  
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         If($SecureGatewayDefaults.PreferredBrokerId -eq 0)
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
                                            {
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite                                                   $SecureGatewayPreferredConnectionBroker = "Automatic"
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                                $Table.Columns.Item(1).Width = 200;    
                                $Table.Columns.Item(2).Width = 250;    
     
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                        }                                           }
                        If($Text)    
                        {                                           Else
                                Line 3 "Name`t`t`t: " $Cert.Name    
                                Line 3 "Description`t`t: " $Cert.Description    
                                Line 3 "Usage`t`t`t: " $Cert.Usage    
                                Line 3 "State`t`t`t: " $Cert.Status.ToString()    
                                Line 3 "Key size`t`t: " $KeySize    
                                Line 3 "Expiration date`t`t: " $Cert.ExpirationDate    
                                Line 3 "Common name`t`t: " $Cert.CommonName    
                                    
                                $cnt=-1    
                                ForEach($Item in $Cert.AlternateNames)    
                                {                                           {
                                        $cnt++                                                   $SecureGatewayPreferredConnectionBroker = (Get-RASBroker -Id $SecureGatewayDefaults.PreferredBrokerId -EA 0 4>$Null).Server
                                            
                                        If($cnt -eq 0)    
                                        {                                           }
                                                Line 3 "Alternate Names`t`t: " $Item    
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                Line 6 "  " $Item                                           #unable to retrieve default, use built-in default values
                                            $SecureGatewayMode = "Normal"
                                            $SecureGatewayForwardRequests = "False"
                                            $SecureGatewayServers = @("localhost:81")
                                            $SecureGatewayPreferredConnectionBroker = "Automatic"
                                        }                                   }
                                }                           }
                                    
                                Line 0 ""    
                        }                           Else
                        If($HTML)    
 
                                $rowdata = @() <>                                 #we don't inherit settings
                                $columnHeaders = @("Name",($Script:htmlsb),$Cert.Name.Replace("<","").Replace(">",""),$htmlwhite)                                   #get the settings configured for this GW
                                $rowdata += @(,("Description",($Script:htmlsb),$Cert.Description,$htmlwhite))                                   $SecureGatewayMode = $SecureGateway.Mode.ToString()
                                $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))                                   $SecureGatewayForwardRequests = $SecureGateway.NormalModeForwarding.ToString()
                                $rowdata += @(,("State",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))    
                                $rowdata += @(,("Key size",($Script:htmlsb),$KeySize,$htmlwhite))    
                                $rowdata += @(,("Expiration date",($Script:htmlsb),$Cert.ExpirationDate,$htmlwhite))    
                                $rowdata += @(,("Common name",($Script:htmlsb),$Cert.CommonName,$htmlwhite))    
                                    
                                $cnt=-1    
                                ForEach($Item in $Cert.AlternateNames)                                   If($SecureGatewayMode -eq "Normal")
 
                                        $cnt++ <>                                         $SecureGatewayServers = $SecureGateway.ForwardHttpServers.Split(";")
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Alternate Names",($Script:htmlsb),$Item,$htmlwhite))    
                                        }                                   }
                                        Else                                   Else
                                        {                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))                                           $SecureGatewayServers = $SecureGateway.ForwardGatewayServers.Split(";")
                                        }    
 
                                 <>                        
                                $msg = "General"                                   If($SecureGateway.PreferredBrokerId -eq 0)
                                $columnWidths = @("200","275")                                   {
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           $SecureGatewayPreferredConnectionBroker = "Automatic"
                                WriteHTMLLine 0 0 ""    
                        }                                   }
                                    Else
                                    {
                                            $SecureGatewayPreferredConnectionBroker = (Get-RASBroker -Id $SecureGateway.PreferredBrokerId -EA 0 4>$Null).Server
                }                                   }
        }                           }
     
        #Settings    
                                  
        #Auditing - not in PoSH    
     
        #Global logging - not in PoSH    
     
        $FarmSettings = Get-RASFarmSettings -SiteId $Site.Id -ea 0 4>$Null    
            
        If(!$?)    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Certificates for Site $($Site.Name)`    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"    
                }    
                If($Text)    
                {    
                        Line 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultModeSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Gateway mode"; Value = $SecureGatewayMode; }) > $Null
                }                                   
                If($HTML)                                   If($SecureGatewayMode -eq "Normal")
                {                                   {
                        WriteHTMLLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"                                           If($SecureGatewayForwardRequests -eq "True")
                }    
        }    
        ElseIf($? -and $Null -eq $FarmSettings)    
        {                                           {
                Write-Host "                                                   $ScriptInformation.Add(@{Data = "Forward requests to HTTP Server"; Value = $SecureGatewayForwardRequests; }) > $Null
                                                    
                                                    $cnt = -1
                No Certificates retrieved for Site $($Site.Name).`                                                   ForEach($Item in $SecureGatewayServers)
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {                                                   {
                        WriteWordLine 0 0 "No Certificates retrieved for Site $($Site.Name)"    
                }                                                           $cnt++
                                                            $tmparray = $Item.Split(":")
                                                            $tmpserver = $tmparray[0]
                                                            $tmpport = $tmparray[1]
                If($Text)                                                           If($cnt -eq 0)
                {                                                           {
                        Line 0 "No Certificates retrieved for Site $($Site.Name)"                                                                   $ScriptInformation.Add(@{Data = "Server(s)"; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null
                }                                                           }
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No Certificates retrieved for Site $($Site.Name)"    
                }    
        }    
        Else                                                           Else
        {                                                           {
                If($MSWord -or $PDF)                                                                   $ScriptInformation.Add(@{Data = ""; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null
                {    
                        WriteWordLine 2 0 "Settings"    
                }                                                           }
                If($Text)    
                {    
                        Line 1 "Settings"    
                }                                                   }
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 "Settings"    
                }                                           }
                                            
                Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings"                                           $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $SecureGatewayPreferredConnectionBroker; }) > $Null
        }                                   }
                                                  Else
        If($MSWord -or $PDF)    
        {                                   {
                WriteWordLine 3 0 "URL redirection"                                           $ScriptInformation.Add(@{Data = "Forward requests to next Secure Gateway in chain (cascaded firewall)"; Value = $SecureGatewayForwardRequests; }) > $Null
                $ScriptInformation = New-Object System.Collections.ArrayList                                          
                $ScriptInformation.Add(@{Data = "Do not redirect the following URLs"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Forwarding Secure Gateway(s)"; Value = ""; }) > $Null
                                            If($SecureGatewayForwardRequests -eq "True")
                                            {
                $cnt = -1                                                   $cnt = -1
                ForEach($Item in $FarmSettings.URLBlacklist)                                                   ForEach($Item in $SecureGatewayServers)
                {                                                   {
                        $cnt++                                                           $cnt++
                                                                                  $tmparray = $Item.Split(":")
                                                            $tmpserver = $tmparray[0]
                                                            $tmpport = $tmparray[1]
                        If($Cnt -eq 0)                                                           If($cnt -eq 0)
                        {                                                           {
                                $ScriptInformation.Add(@{Data = "     Url"; Value = $Item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "Server(s)"; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null
                        }                                                           }
                        Else                                                           Else
                        {                                                           {
                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = "Server: $($tmpserver)  Port: $($tmpport)"; }) > $Null
                        }                                                           }
                }                                                   }
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sitess"; Value = $FarmSettings.ReplicateURLRedirection.ToString(); }) > $Null                                           }
                                    }
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 2 "URL redirection"                                   Line 3 "Inherit default settings`t`t: " $SecureGateway.InheritDefaultModeSettings.ToString()
                Line 3 "Do not redirect the following URLs`t: "                                   Line 3 "Gateway mode`t`t`t`t: " $SecureGatewayMode
                                    If($SecureGatewayMode -eq "Normal")
                                    {
                                            Line 3 "Forward requests to HTTP Server`t`t: " $SecureGatewayForwardRequests
                                            
                $cnt = -1                                           $cnt = -1
                ForEach($Item in $FarmSettings.URLBlacklist)                                           ForEach($Item in $SecureGatewayServers)
                {                                           {
                        $cnt++                                                   $cnt++
                                                                          $tmparray = $Item.Split(":")
                                                    $tmpserver = $tmparray[0]
                                                    $tmpport = $tmparray[1]
                        If($Cnt -eq 0)                                                   If($cnt -eq 0)
                        {                                                   {
                                Line 7 "     Url: " $Item                                                           Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"
                        }                                                   }
                        Else                                                   Else
                        {                                                   {
                                Line 8 "  " $Item                                                           Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"
                        }                                                   }
                }                                           }
                Line 3 "Settings are replicated to all Sites`t: " $FarmSettings.ReplicateURLRedirection.ToString()                                          
                Line 0 ""                                           Line 3 "Preferred Connection Broker`t`t: " $SecureGatewayPreferredConnectionBroker
        }                                   }
        If($HTML)                                   Else
        {                                   {
                WriteHTMLLine 3 0 "URL redirection"                                           Line 3 "Forward requests to next "
                $rowdata = @()                                           Line 3 "Secure Gateway"
                $columnHeaders = @("Do not redirect the following URLs",($Script:htmlsb),"",$htmlwhite)                                           Line 3 "in chain (cascaded firewall)`t`t: " $SecureGatewayForwardRequests
                                            
                                            Line 3 "Forwarding Secure Gateway(s)"
                                            If($SecureGatewayForwardRequests -eq "True")
                                            {
                $cnt = -1                                                   $cnt = -1
                ForEach($Item in $FarmSettings.URLBlacklist)                                                   ForEach($Item in $SecureGatewayServers)
                {                                                   {
                        $cnt++                                                           $cnt++
                                                                                  $tmparray = $Item.Split(":")
                                                            $tmpserver = $tmparray[0]
                                                            $tmpport = $tmparray[1]
                        If($Cnt -eq 0)                                                           If($cnt -eq 0)
                        {                                                           {
                                $rowdata += @(,(    URL",($Script:htmlsb),$Item,$htmlwhite))                                                                   Line 3 "Server(s)`t`t`t`t: " "Server: $($tmpserver)`tPort: $($tmpport)"
                        }                                                           }
                        Else                                                           Else
                        {                                                           {
                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))                                                                   Line 8 "  " "Server: $($tmpserver)`tPort: $($tmpport)"
                        }                                                           }
                }                                                   }
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FarmSettings.ReplicateURLRedirection.ToString(),$htmlwhite))    
     
                $msg = ""    
                $columnWidths = @("200","275")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
     
                WriteHTMLLine 0 0 ""    
        }                                           }
                    
        $RASNotificationHandlers = Get-RASNotification -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve notification handlers information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve notification handlers information"    
                }                                   }
                If($Text)    
                {                                   Line 0 ""
                        Line 0 "Unable to retrieve notification handlers information"    
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve notification handlers information"                                   $rowdata = @()
                }                                   $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultModeSettings.ToString(),$htmlwhite)
        }                                   $rowdata += @(,("Gateway mode",($Script:htmlsb),$SecureGatewayMode,$htmlwhite))
        ElseIf($? -and $null -eq $RASNotificationHandlers)                                   If($SecureGatewayMode -eq "Normal")
        {                                   {
                Write-Host "                                           $rowdata += @(,("Forward requests to HTTP Server",($Script:htmlsb),$SecureGatewayForwardRequests,$htmlwhite))
                No notification handlers information was found                                          
                " -ForegroundColor White                                           $cnt = -1
                If($MSWord -or $PDF)                                           ForEach($Item in $SecureGatewayServers)
                {                                           {
                        WriteWordLine 0 0 "No notification handlers information was found"    
                }                                                   $cnt++
                                                    $tmparray = $Item.Split(":")
                                                    $tmpserver = $tmparray[0]
                                                    $tmpport = $tmparray[1]
                If($Text)                                                   If($cnt -eq 0)
                {                                                   {
                        Line 0 "No notification handlers information was found"                                                           $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
                }                                                   }
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No notification handlers information was found"    
                }    
        }    
        Else                                                   Else
        {                                                   {
                OutputRASNotifications $RASNotificationHandlers                                                           $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
        }                                                   }
            
        $RASNotificationScripts = Get-RASNotificationScript -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve notification scripts information    
                "    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "Unable to retrieve notification scripts information"    
                }                                           }
                If($Text)    
                {                                           
                        Line 0 "Unable to retrieve notification scripts information"                                           $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$SecureGatewayPreferredConnectionBroker,$htmlwhite))
                }                                   }
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "Unable to retrieve notification scripts information"    
                }    
        }    
        ElseIf($? -and $null -eq $RASNotificationScripts)    
        {    
                Write-Host "    
                No notification scripts information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No notification scripts information was found"    
                }    
                If($Text)    
                {    
                        Line 0 "No notification scripts information was found"    
                }    
                If($HTML)    
                {    
                        WriteHTMLLine 0 0 "No notification scripts information was found"    
                }    
        }    
        Else                                   Else
        {                                   {
                OutputRASNotificationScripts $RASNotificationScripts                                           $rowdata += @(,("Forward requests to next RAS Secure Client Gateway in chain (cascaded firewall)",($Script:htmlsb),$SecureGatewayForwardRequests,$htmlwhite))
        }    
                                                          
        If($MSWord -or $PDF)                                           $rowdata += @(,("Forwarding Secure Gateway(s)",($Script:htmlsb),"",$htmlwhite))
        {                                           If($SecureGatewayForwardRequests -eq "True")
                WriteWordLine 3 0 "Client settings"    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                If($FarmSettings.SendHDIcons)    
                {                                           {
                        $ScriptInformation.Add(@{Data = "Published application icons"; Value = "Send high resolution icons (uses more network bandwidth)"; }) > $Null    
                }                                                   $cnt = -1
                Else                                                   ForEach($Item in $SecureGatewayServers)
                {                                                   {
                        $ScriptInformation.Add(@{Data = "Published application icons"; Value = "Send standard resolution icons"; }) > $Null    
                }    
                $ScriptInformation.Add(@{Data = "Enable overlay icon"; Value = $FarmSettings.EnableOverlayIcons.ToString(); }) > $Null    
                $ScriptInformation.Add(@{Data = "Show password expiration reminder"; Value = $FarmSettings.ShowPasswordExpiry.ToString(); }) > $Null    
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FarmSettings.ReplicateSendHDIcons.ToString(); }) > $Null    
                                                            $cnt++
                $Table = AddWordTable -Hashtable $ScriptInformation `                                                           $tmparray = $Item.Split(":")
                -Columns Data,Value `                                                           $tmpserver = $tmparray[0]
                -List `                                                           $tmpport = $tmparray[1]
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 200;    
                $Table.Columns.Item(2).Width = 250;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
     
                WriteWordLine 0 0 ""    
        }    
        If($Text)                                                           If($cnt -eq 0)
        {                                                           {
                Line 2 "Client settings"                                                                   $rowdata += @(,("Server(s)",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
                If($FarmSettings.SendHDIcons)    
                {    
                        Line 3 "Published application icons`t`t: " "Send high resolution icons (uses more network bandwidth)" ""    
                }                                                           }
                Else                                                           Else
                {                                                           {
                        Line 3 "Published application icons`t`t: " "Send standard resolution icons" ""                                                                   $rowdata += @(,("",($Script:htmlsb),"Server: $($tmpserver)  Port: $($tmpport)",$htmlwhite))
                }                                                           }
                Line 3 "Enable overlay icon`t`t`t: " $FarmSettings.EnableOverlayIcons.ToString()    
                Line 3 "Show password expiration reminder`t: " $FarmSettings.ShowPasswordExpiry.ToString()    
                Line 3 "Settings are replicated to all Sites`t: " $FarmSettings.ReplicateSendHDIcons.ToString()    
                Line 0 ""    
        }                                                   }
        If($HTML)    
        {    
                WriteHTMLLine 3 0 "Client settings"    
                $rowdata = @()    
                If($FarmSettings.SendHDIcons)    
                {    
                        $columnHeaders = @("Published application icons",($Script:htmlsb),"Send high resolution icons (uses more network bandwidth)",$htmlwhite)    
                }                                           }
                Else    
                {    
                        $columnHeaders = @("Published application icons",($Script:htmlsb),"Send standard resolution icons",$htmlwhite)    
                }                                   }
                $rowdata += @(,("Enable overlay icon",($Script:htmlsb),$FarmSettings.EnableOverlayIcons.ToString(),$htmlwhite))    
                $rowdata += @(,("Show password expiration reminder",($Script:htmlsb),$FarmSettings.ShowPasswordExpiry.ToString(),$htmlwhite))    
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FarmSettings.ReplicateSendHDIcons.ToString(),$htmlwhite))    
 
                $msg = "" <>                                 $msg = "Mode"
                $columnWidths = @("200","275")                                   $columnWidths = @("300","275")
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
        }                           }
 
        $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id} <>                         #Network
                                  
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve FSLogix Settings information    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve FSLogix Settings information"                                   WriteWordLine 4 0 "Network"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve FSLogix Settings information"                                   Line 2 "Network"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve FSLogix Settings information"                                   #Nothing
                }                           }
        }                           
        ElseIf($? -and $null -eq $FSLogixDeploymentSettings)                           If($SecureGateway.InheritDefaultNetworkSettings)
        {                           {
                Write-Host "                                   #do we inherit site defaults?
                No FSLogix Settings information was found                                   #yes we do, get the default settings for the Site
                " -ForegroundColor White                                   #use the Site default settings
                If($MSWord -or $PDF)    
                {    
                        WriteWordLine 0 0 "No FSLogix Settings information was found"                                   $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                }                                   
                If($Text)                                   If($? -and $Null -ne $SecureGatewayDefaults)
                {                                   {
                        Line 0 "No FSLogix Settings information was found"                                           $SecureGatewayEnableRASSecureClientGatewayPort             = $SecureGatewayDefaults.EnableGatewayPort.ToString()
                                            $SecureGatewayRASSecureClientGatewayPort                   = $SecureGatewayDefaults.GatewayPort.ToString()
                                            $SecureGatewayEnableRDPPort                                = $SecureGatewayDefaults.EnableRDP.ToString()
                                            $SecureGatewayRDPPort                                      = $SecureGatewayDefaults.RDPPort.ToString()
                                            $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress = $SecureGatewayDefaults.Broadcast.ToString()
                                            $SecureGatewayEnableRDPUPDDataTunneling                    = $SecureGatewayDefaults.EnableRDPUDP.ToString()
                                            $SecureGatewayEnableDeviceManagerPort                      = $SecureGatewayDefaults.EnableDeviceManagerPort.ToString()
                                            $SecureGatewayDeviceManagerPort                            = "20009"
                                            $SecureGatewayEnableRDPDOSAttackFilter                     = $SecureGatewayDefaults.DOSPro.ToString()
                                            $SecureGatewayCipherPreference                             = $SecureGatewayDefaults.CipherPreference.ToString()
                }                                   }
                If($HTML)                                   Else
                {                                   {
                        WriteHTMLLine 0 0 "No FSLogix Settings information was found"                                           #unable to retrieve default, use built-in default values
                                            $SecureGatewayEnableRASSecureClientGatewayPort             = "True"
                                            $SecureGatewayRASSecureClientGatewayPort                   = "80"
                                            $SecureGatewayEnableRDPPort                                = "False"
                                            $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress = "True"
                                            $SecureGatewayEnableRDPUPDDataTunneling                    = "True"
                                            $SecureGatewayEnableDeviceManagerPort                      = "True"
                                            $SecureGatewayDeviceManagerPort                            = "20009"
                                            $SecureGatewayEnableRDPDOSAttackFilter                     = "True"
                                            $SecureGatewayCipherPreference                             = "True"
                }                                   }
        }                           }
        Else                           Else
        {                           {
                Switch($FSLogixDeploymentSettings.InstallType)                                   #we don't inherit settings
                {                                   #get the settings configured for this GW
                        "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}                                   $SecureGatewayEnableRASSecureClientGatewayPort             = $SecureGateway.EnableGatewayPort.ToString()
                        "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}                                   $SecureGatewayRASSecureClientGatewayPort                   = $SecureGateway.GatewayPort.ToString()
                        "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}                                   $SecureGatewayEnableRDPPort                                = $SecureGateway.EnableRDP.ToString()
                        "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}                                   $SecureGatewayRDPPort                                      = $SecureGateway.RDPPort.ToString()
                        Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}                                   $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress = $SecureGateway.Broadcast.ToString()
                                    $SecureGatewayEnableRDPUPDDataTunneling                    = $SecureGateway.EnableRDPUDP.ToString()
                                    $SecureGatewayEnableDeviceManagerPort                      = $SecureGateway.EnableDeviceManagerPort.ToString()
                                    $SecureGatewayDeviceManagerPort                            = "20009"
                                    $SecureGatewayEnableRDPDOSAttackFilter                     = $SecureGateway.DOSPro.ToString()
                                    $SecureGatewayCipherPreference                             = $SecureGateway.CipherPreference.ToString()
                }                           }
                                          
                $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL    
                $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath    
                $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName    
                $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate    
                    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 3 0 "Features"    
                        WriteWordLine 4 0 "FSLogix"    
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultNetworkSettings.ToString(); }) > $Null
                        If($FSLogixDeploymentSettings.InstallType -eq "Online")                                   $ScriptInformation.Add(@{Data = "Enable Secure Gateway Port"; Value = $SecureGatewayEnableRASSecureClientGatewayPort; }) > $Null
                        {                                   $ScriptInformation.Add(@{Data = "Secure Gateway Port"; Value = $SecureGatewayRASSecureClientGatewayPort; }) > $Null
                                $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null                                   $ScriptInformation.Add(@{Data = "  Only allow Let's Encrypt verification"; Value = "Can't find"; }) > $Null
                        }                                   $ScriptInformation.Add(@{Data = "Enable RDP Port"; Value = $SecureGatewayEnableRDPPort; }) > $Null
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                        {    
                                $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null                                   $ScriptInformation.Add(@{Data = "RDP Port"; Value = $SecureGatewayRDPPort; }) > $Null
                        }                                   $ScriptInformation.Add(@{Data = "Enable Broadcast RAS Secure Client Gateway Address"; Value = $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress; }) > $Null
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")                                   $ScriptInformation.Add(@{Data = "Enable RDP UDP Data Tunneling"; Value = $SecureGatewayEnableRDPUPDDataTunneling; }) > $Null
                        {                                   $ScriptInformation.Add(@{Data = "Enable Device Manager Port"; Value = $SecureGatewayEnableDeviceManagerPort; }) > $Null
                                $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Device Manager Port"; Value = $SecureGatewayDeviceManagerPort; }) > $Null
                        }    
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable RDP DOS Attack Filter"; Value = $SecureGatewayEnableRDPDOSAttackFilter; }) > $Null
                            
                        $Table = AddWordTable -Hashtable $ScriptInformation `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 2 "Features"    
                        Line 3 "FSLogix"    
                        Line 4 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod    
                        If($FSLogixDeploymentSettings.InstallType -eq "Online")    
                        {    
                                Line 4 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL    
                        }    
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                        {    
                                Line 11 ": " $FSLogixDeploymentSettingsNetworkDrivePath    
                        }    
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")    
                        {    
                                Line 11 ": " $FSLogixDeploymentSettingsInstallerFileName    
                        }    
                        Line 4 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()                                   Line 3 "Inherit default settings`t`t: " $SecureGateway.InheritDefaultNetworkSettings.ToString()
                                    Line 3 "Enable Secure Gateway Port`t`t: " $SecureGatewayEnableRASSecureClientGatewayPort
                                    Line 3 "Secure Gateway Port`t`t`t: " $SecureGatewayRASSecureClientGatewayPort
                                    Line 3 "  Only allow Let's Encrypt verification`t: " "Can't find"
                                    Line 3 "Enable RDP Port`t`t`t`t: " $SecureGatewayEnableRDPPort
                                    Line 3 "RDP Port`t`t`t`t: " $SecureGatewayRDPPort
                                    Line 3 "Enable Broadcast Secure Gateway Address`t: " $SecureGatewayEnableBroadcastRASSecureClientGatewayAddress
                                    Line 3 "Enable RDP UDP Data Tunneling`t`t: " $SecureGatewayEnableRDPUPDDataTunneling
                                    Line 3 "Enable Device Manager Port`t`t: " $SecureGatewayEnableDeviceManagerPort
                                    Line 3 "Device Manager Port`t`t`t: " $SecureGatewayDeviceManagerPort
                                    Line 3 "Enable RDP DOS Attack Filter`t`t: " $SecureGatewayEnableRDPDOSAttackFilter
                                    Line 0 ""
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 3 0 "Features"    
                        $rowdata = @()                                   $rowdata = @()
                        $columnHeaders = @("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite)                                   $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultNetworkSettings.ToString(),$htmlwhite)
                        If($FSLogixDeploymentSettings.InstallType -eq "Online")                                   $rowdata += @(,("Enable Secure Gateway Port",($Script:htmlsb),$SecureGatewayEnableRASSecureClientGatewayPort,$htmlwhite))
                        {                                   $rowdata += @(,("Secure Gateway Port",($Script:htmlsb),$SecureGatewayRASSecureClientGatewayPort,$htmlwhite))
                                $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))                                   $rowdata += @(,("  Only allow Let's Encrypt verification: ",($Script:htmlsb),"Can't find",$htmlwhite))
                        }                                   $rowdata += @(,("Enable RDP Port",($Script:htmlsb),$SecureGatewayEnableRDPPort,$htmlwhite))
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")    
                        {    
                                $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))                                   $rowdata += @(,("RDP Port",($Script:htmlsb),$SecureGatewayRDPPort,$htmlwhite))
                        }                                   $rowdata += @(,("Enable Broadcast RAS Secure Client Gateway Address",($Script:htmlsb),$SecureGatewayEnableBroadcastRASSecureClientGatewayAddress,$htmlwhite))
                        ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")                                   $rowdata += @(,("Enable RDP UDP Data Tunneling",($Script:htmlsb),$SecureGatewayEnableRDPUPDDataTunneling,$htmlwhite))
                        {                                   $rowdata += @(,("Enable Device Manager Port",($Script:htmlsb),$SecureGatewayEnableDeviceManagerPort,$htmlwhite))
                                $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))                                   $rowdata += @(,("Device Manager Port",($Script:htmlsb),$SecureGatewayDeviceManagerPort,$htmlwhite))
                        }    
                        $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))                                   $rowdata += @(,("Enable RDP DOS Attack Filter",($Script:htmlsb),$SecureGatewayEnableRDPDOSAttackFilter,$htmlwhite))
                                            
                        $msg = "FSLogix"                                   $msg = "Network"
                        $columnWidths = @("200","250")                                   $columnWidths = @("300","275")
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                }                           }
        }    
}    
#endregion    
                            #SSL/TLS
#region process load balancing    
Function ProcessLoadBalancing    
{    
        Param([object]$Site)    
                                  
        Write-Verbose "$(Get-Date -Format G): Processing Load Balancing"    
            
        OutputLoadBalancingSectionPage    
            
        Write-Verbose "$(Get-Date -Format G): `tProcessing Load Balancing"    
            
        $results = Get-RASLBSettings -SiteId $Site.Id -EA 0 4>$Null    
            
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Load Balancing information    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Load Balancing information"                                   WriteWordLine 4 0 "SSL/TLS"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve Load Balancing information"                                   Line 2 "SSL/TLS"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Load Balancing information"    
                }                                   #Nothing
        }                           }
        ElseIf($? -and $null -eq $results)    
        {                           
                Write-Host "    
                No Load Balancing information was found    
                " -ForegroundColor White    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "No Load Balancing information was found"                                   $ScriptInformation = New-Object System.Collections.ArrayList
                }                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultSslTlsSettings.ToString(); }) > $Null
                If($Text)    
                {    
                        Line 0 "No Load Balancing information was found"                                   If($SecureGatewayEnableHSTS -eq "False")
                }    
                If($HTML)    
                {                                   {
                        WriteHTMLLine 0 0 "No Load Balancing information was found"                                           $ScriptInformation.Add(@{Data = "HSTS is off"; Value = ""; }) > $Null
                }                                   }
        }    
        Else                                   Else
        {                                   {
                OutputRASLBSettings $results                                           $ScriptInformation.Add(@{Data = "HSTS is on"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Enforce HTTP strict transport security (HSTS)"; Value = $SecureGatewayEnableHSTS; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Browser caache time"; Value = "$SecureGatewayHSTSMaxage months"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Include subdomains"; Value = $SecureGatewayHSTSIncludeSubdomains; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Preload"; Value = $SecureGatewayHSTSPreload; }) > $Null
        }                                   }
            
                                    $ScriptInformation.Add(@{Data = "Enable SSL"; Value = $SecureGatewayEnableSSL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "on Port"; Value = $SecureGatewayEnableSSLOnPort; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Accepted SSL Versions"; Value = $SecureGatewayAcceptedSSLVersions; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Cipher Strength"; Value = $SecureGatewayCipherStrength; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Cipher"; Value = $SecureGatewayCipher; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Use ciphers according to server preference"; Value = $SecureGatewayCipherPreference; }) > $Null
        $results = Get-RASCPUOptimizationSettings -SiteId $Site.Id -EA 0 4>$Null                                   $ScriptInformation.Add(@{Data = "Certificates"; Value = $SecureGatewayCertificates; }) > $Null
            
        If(!($?))                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
        {    
        Write-Warning "                                   SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
        `n    
        Unable to retrieve CPU Optimization information                                   $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
        "    
                If($MSWord -or $PDF)                                   $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
                {    
                        WriteWordLine 0 0 "Unable to retrieve CPU Optimization information"                                   FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve CPU Optimization information"                                   Line 3 "Inherit default settings`t`t  : " $SecureGateway.InheritDefaultSslTlsSettings.ToString()
                }    
                If($HTML)                                   If($SecureGatewayEnableHSTS -eq "False")
                {                                   {
                        WriteHTMLLine 0 0 "Unable to retrieve CPU Optimization information"                                           Line 3 "HSTS is off"
                }                                   }
        }                                   Else
        ElseIf($? -and $null -eq $results)    
        {                                   {
                Write-Host "                                           Line 3 "HSTS is on"
                No CPU Optimization information was found                                           Line 3 "Enforce HTTP strict transport security`t  : " $SecureGatewayEnableHSTS
                " -ForegroundColor White                                           Line 3 "Browser caache time`t`t`t  : " "$SecureGatewayHSTSMaxage months"
                If($MSWord -or $PDF)                                           Line 3 "Include subdomains`t`t`t  : " $SecureGatewayHSTSIncludeSubdomains
                {                                           Line 3 "Preload`t`t`t`t`t  : " $SecureGatewayHSTSPreload
                        WriteWordLine 0 0 "No CPU Optimization information was found"    
                }                                   }
                If($Text)    
                {    
                        Line 0 "No CPU Optimization information was found"                                   Line 3 "Enable SSL`t`t`t`t  : " $SecureGatewayEnableSSL
                                    Line 3 "on Port`t`t`t`t`t  : " $SecureGatewayEnableSSLOnPort
                                    Line 3 "Accepted SSL Versions`t`t`t  : " $SecureGatewayAcceptedSSLVersions
                                    Line 3 "Cipher Strength`t`t`t`t  : " $SecureGatewayCipherStrength
                                    Line 3 "Cipher`t`t`t`t`t  : " $SecureGatewayCipher
                                    Line 3 "Use ciphers according to server preference: " $SecureGatewayCipherPreference
                                    Line 3 "Certificates`t`t`t`t  : " $SecureGatewayCertificates
                                    Line 0 ""
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "No CPU Optimization information was found"                                   $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultSslTlsSettings.ToString(),$htmlwhite)
     
                                    If($SecureGatewayEnableHSTS -eq "False")
                }                                   {
                                            $rowdata += @(,("HSTS is off",($Script:htmlsb),"",$htmlwhite))
        }                                   }
        Else                                   Else
        {                                   {
                OutputCPUOptimizationSettings $results                                           $rowdata += @(,("HSTS is on",($Script:htmlsb),,$htmlwhite))
                                            $rowdata += @(,("Enforce HTTP strict transport security (HSTS)",($Script:htmlsb),$SecureGatewayEnableHSTS,$htmlwhite))
                                            $rowdata += @(,("Browser caache time",($Script:htmlsb),"$SecureGatewayHSTSMaxage months",$htmlwhite))
                                            $rowdata += @(,("Include subdomains",($Script:htmlsb),$SecureGatewayHSTSIncludeSubdomains,$htmlwhite))
                                            $rowdata += @(,("Preload",($Script:htmlsb),$SecureGatewayHSTSPreload,$htmlwhite))
        }                                   }
     
                                    $rowdata += @(,("Enable SSL",($Script:htmlsb),$SecureGatewayEnableSSL,$htmlwhite))
                                    $rowdata += @(,("on Port",($Script:htmlsb),$SecureGatewayEnableSSLOnPort,$htmlwhite))
                                    $rowdata += @(,("Accepted SSL Versions",($Script:htmlsb),$SecureGatewayAcceptedSSLVersions,$htmlwhite))
                                    $rowdata += @(,("Cipher Strength",($Script:htmlsb),$SecureGatewayCipherStrength,$htmlwhite))
                                    $rowdata += @(,("Cipher",($Script:htmlsb),$SecureGatewayCipher,$htmlwhite))
                                    $rowdata += @(,("Use ciphers according to server preference",($Script:htmlsb),$SecureGatewayCipherPreference,$htmlwhite))
                                    $rowdata += @(,("Certificates",($Script:htmlsb),$SecureGatewayCertificates,$htmlwhite))
     
                                    $msg = "SSL/TLS"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
}                           }
 
Function OutputLoadBalancingSectionPage <>                         #HTML5
{                           
        If($MSWord -or $PDF)                           If($MSWord -or $PDF)
        {                           {
                $Script:Selection.InsertNewPage()    
                WriteWordLine 1 0 "Load Balancing"                                   WriteWordLine 4 0 "User Portal"
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 0 "Load Balancing"                                   Line 2 "User Portal"
        }                           }
        If($HTML)                           If($HTML)
        {                           {
                WriteHTMLLine 1 0 "Load Balancing"    
        }                                   #Nothing
}                           }
                            
Function OutputRASLBSettings                           If($SecureGateway.InheritDefaultUserPortalSettings)
{                           {
        Param([object] $RASLBSettings)                                   #do we inherit site defaults?
                                    #yes we do, get the default settings for the Site
                                    #use the Site default settings
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Load Balancing"                                   $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                          
        If($MSWord -or $PDF)                                   If($? -and $Null -ne $SecureGatewayDefaults)
        {                                   {
                WriteWordLine 2 0 "Load Balancing"                                           $SecureGatewayEnableUserPortalClient = $SecureGatewayDefaults.EnableUserPortal.ToString()
        }                                           
        If($Text)                                           Switch($SecureGatewayDefaults.LaunchMethod)
        {                                           {
                Line 1 "Load Balancing"                                                   "ParallelsClientAndWebClient"   {$SecureGatewayLaunchSessionsUsing = "Parallels Client with fallback to Browser"; Break}
                                                    "ParallelsClient"                               {$SecureGatewayLaunchSessionsUsing = "Parallels Client only"; Break}
                                                    "WebClient"                                             {$SecureGatewayLaunchSessionsUsing = "Browser Only"; Break}
                                                    Default                                                 {$SecureGatewayLaunchSessionsUsing = "Unable to determine Launch sessions using: $($SecureGatewayDefaults.LaunchMethod)"; Break}
        }                                           }
        If($HTML)                                          
                                            Switch ($SecureGatewayDefaults.FileTransferMode)
        {                                           {
                WriteHTMLLine 2 0 "Load Balancing"                                                   "Bidirectional"         {$SecureGatewayFileTransferMode = "Bidirectional"; Break}
                                                    "Disabled"                      {$SecureGatewayFileTransferMode = "Disabled"; Break}
                                                    "ClientToServer"        {$SecureGatewayFileTransferMode = "Client to server only"; Break}
                                                    "ServerToClient"        {$SecureGatewayFileTransferMode = "Server to client only"; Break}
                                                    Default                         {$SecureGatewayFileTransferMode = "Unable to determine File Transfer mode: $($SecureGatewayDefaults.FileTransferMode)"; Break}
        }                                           }
            
        Switch ($RASLBSettings.Method)                                           Switch ($SecureGatewayDefaults.ClipboardDirection)
        {                                           {
                "ResourceBased" {$RASLBSettingsMethod = "Resource Based"; Break}                                                   "Bidirectional        {$SecureGatewayClipboardTransferMode = "Bidirectional"; Break}
                "RoundRobin"    {$RASLBSettingsMethod = "Round Robin"; Break}                                                   "Disabled"                      {$SecureGatewayClipboardTransferMode = "Disabled"; Break}
                                                    "ClientToServer"        {$SecureGatewayClipboardTransferMode = "Client to server only"; Break}
                                                    "ServerToClient"        {$SecureGatewayClipboardTransferMode = "Server to client only"; Break}
                Default                 {$RASLBSettingsMethod = "Unable to determine Load balancing method: $($RASLBSettings.Method)"; Break}                                                   Default                         {$SecureGatewayClipboardTransferMode = "Unable to determine Clipboard mode: $($SecureGatewayDefaults.ClipboardDirection)"; Break}
        }                                           }
            
        If($MSWord -or $PDF)    
        {    
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Method"; Value = $RASLBSettingsMethod; }) > $Null    
                $ScriptInformation.Add(@{Data = "Counters"; Value = ""; }) > $Null    
                $ScriptInformation.Add(@{Data = "     User Sessions"; Value = $RASLBSettings.SessionsCounter; }) > $Null    
                $ScriptInformation.Add(@{Data = "     Memory"; Value = $RASLBSettings.MemoryCounter; }) > $Null                                           $SecureGatewayAllowLaunchMethod          = $SecureGatewayDefaults.AllowLaunchMethod.ToString()
                $ScriptInformation.Add(@{Data = "     CPU"; Value = $RASLBSettings.CPUCounter; }) > $Null                                           $SecureGatewayAllowAppsInNewTab          = $SecureGatewayDefaults.AllowAppsInNewTab.ToString()
                $ScriptInformation.Add(@{Data = "Reconnect to disconnected sessions"; Value = $RASLBSettings.ReconnectDisconnect; }) > $Null    
                $ScriptInformation.Add(@{Data = "Reconnect sessions using client's IP address only"; Value = $RASLBSettings.ReconnectUsingIPOnly; }) > $Null    
                $ScriptInformation.Add(@{Data = "Limit each user to one session per desktop"; Value = $RASLBSettings.ReconnectUser; }) > $Null                                           $SecureGatewayUsePreWin2000LoginFormat   = $SecureGatewayDefaults.UsePreWin2000LoginFormat.ToString()
                                            $SecureGatewayAllowEmbed                 = $SecureGatewayDefaults.AllowEmbed.ToString()
                                            $SecureGatewayAllowFileTransfer          = $SecureGatewayDefaults.AllowFileTransfer.ToString()
                $ScriptInformation.Add(@{Data = "Disable Microsoft RD Connection Broker"; Value = $RASLBSettings.DisableRDSLB; }) > $Null                                           $SecureGatewayAllowClipboard             = $SecureGatewayDefaults.AllowClipboard.ToString()
                                            $SecureGatewayAllowCORS                  = $SecureGatewayDefaults.AllowCORS
                                            $SecureGatewayAllowedDomainsForCORS      = $SecureGatewayDefaults.AllowedDomainsForCORS
                                            $SecureGatewayBrowserCacheTimeInMonths   = $SecureGatewayDefaults.BrowserCacheTimeInMonths
                $ScriptInformation.Add(@{Data = "Declare Agent dead if not responding for"; Value = "$($RASLBSettings.DeadTimeout) seconds"; }) > $Null                                           $SecureGatewayEnableAlternateNLBHostname = $SecureGatewayDefaults.EnableAlternateNLBHost.ToString()
                $ScriptInformation.Add(@{Data = "Agent Refresh Time"; Value = "$($RASLBSettings.RefreshTimeout) seconds"; }) > $Null                                           $SecureGatewayAlternameNLBHostname       = $SecureGatewayDefaults.AlternateNLBHost
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASLBSettings.Replicate.ToString(); }) > $Null                                           $SecureGatewayEnableAlternateNLBPort     = $SecureGatewayDefaults.EnableAlternateNLBPort.ToString()
                                            $SecureGatewayAlternateNLBPort           = $SecureGatewayDefaults.AlternateNLBPort.ToString()
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 275;    
                $Table.Columns.Item(2).Width = 150;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""    
        }                                   }
        If($Text)                                   Else
        {                                   {
                Line 2 "Method`t`t`t: " $RASLBSettingsMethod                                           #unable to retrieve default, use built-in default values
                Line 2 "Counters"                                           $SecureGatewayEnableUserPortalClient     = "True"
                Line 3 "User Sessions`t: " $RASLBSettings.SessionsCounter                                           $SecureGatewayLaunchSessionsUsing        = "Parallels Client with gallback to Browser"
                                            $SecureGatewayAllowLaunchMethod          = "True"
                                            $SecureGatewayAllowAppsInNewTab          = "False"
                                            $SecureGatewayUsePreWin2000LoginFormat   = "True"
                                            $SecureGatewayAllowEmbed                 = "False"
                                            $SecureGatewayAllowFileTransfer          = "True"
                                            $SecureGatewayAllowClipboard             = "True"
                                            $SecureGatewayAllowCORS                  = "False"
                                            $SecureGatewayAllowedDomainsForCORS      = @()
                                            $SecureGatewayBrowserCacheTimeInMonths   = 12
                                            $SecureGatewayEnableAlternateNLBHostname = "False"
                Line 3 "Memory`t`t: " $RASLBSettings.MemoryCounter                                           $SecureGatewayAlternameNLBHostname       = ""
                Line 3 "CPU`t`t: " $RASLBSettings.CPUCounter                                           $SecureGatewayEnableAlternateNLBPort     = "False"
                Line 2 "Reconnect to disconnected sessions`t`t`t: " $RASLBSettings.ReconnectDisconnect                                           $SecureGatewayAlternateNLBPort           = "8443"
                Line 2 "Reconnect sessions using client's IP address only`t: " $RASLBSettings.ReconnectUsingIPOnly                                           $SecureGatewayClipboardTransferMode      = "Bidirectional"
                Line 2 "Limit each user to one session per desktop`t`t: " $RASLBSettings.ReconnectUser    
                Line 2 "Disable Microsoft RD Connection Broker`t`t`t: " $RASLBSettings.DisableRDSLB    
                Line 2 "Declare Agent dead if not responding for`t`t: " "$($RASLBSettings.DeadTimeout) seconds"    
                Line 2 "Agent Refresh Time`t`t`t`t`t: " "$($RASLBSettings.RefreshTimeout) seconds"    
                Line 2 "Settings are replicated to all Sites`t`t`t: " $RASLBSettings.Replicate.ToString()    
                Line 0 ""    
        }                                   }
        If($HTML)    
        {    
                $rowdata = @()    
                $columnHeaders = @("Method",($Script:htmlsb),$RASLBSettingsMethod,$htmlwhite)    
                $rowdata += @(,("Counters",($Script:htmlsb),"",$htmlwhite))    
                $rowdata += @(,("     User Sessions",($Script:htmlsb),$RASLBSettings.SessionsCounter.ToString(),$htmlwhite))    
                $rowdata += @(,("     Memory",($Script:htmlsb),$RASLBSettings.MemoryCounter.ToString(),$htmlwhite))    
                $rowdata += @(,("     CPU",($Script:htmlsb),$RASLBSettings.CPUCounter.ToString(),$htmlwhite))    
                $rowdata += @(,("Reconnect to disconnected sessions",($Script:htmlsb),$RASLBSettings.ReconnectDisconnect.ToString(),$htmlwhite))    
                $rowdata += @(,("Reconnect sessions using client's IP address only",($Script:htmlsb),$RASLBSettings.ReconnectUsingIPOnly.ToString(),$htmlwhite))    
                $rowdata += @(,("Limit each user to one session per desktop",($Script:htmlsb),$RASLBSettings.ReconnectUser.ToString(),$htmlwhite))    
                $rowdata += @(,("Disable Microsoft RD Connection Broker",($Script:htmlsb),$RASLBSettings.DisableRDSLB.ToString(),$htmlwhite))    
                $rowdata += @(,("Declare Agent dead if not responding for",($Script:htmlsb),"$($RASLBSettings.DeadTimeout) seconds",$htmlwhite))    
                $rowdata += @(,("Agent Refresh Time",($Script:htmlsb),"$($RASLBSettings.RefreshTimeout) seconds",$htmlwhite))    
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASLBSettings.Replicate.ToString(),$htmlwhite))    
     
                $msg = ""    
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }                           }
}    
                            Else
Function OutputCPUOptimizationSettings    
{                           {
        Param([object] $RASCPUSettings)                                   #we don't inherit settings
                                          #get the settings configured for this GW
        Write-Verbose "$(Get-Date -Format G): `t`tOutput CPU Optimization"                                   $SecureGatewayEnableUserPortalClient = $SecureGateway.EnableUserPortal.ToString()
                                          
        If($MSWord -or $PDF)                                   Switch($SecureGatewayDefaults.LaunchMethod)
        {                                   {
                WriteWordLine 2 0 "CPU Optimization"                                           "ParallelsClientAndWebClient"   {$SecureGatewayLaunchSessionsUsing = "Parallels Client with fallback to Browser"; Break}
                                            "ParallelsClient"                               {$SecureGatewayLaunchSessionsUsing = "Parallels Client only"; Break}
                                            "WebClient"                                             {$SecureGatewayLaunchSessionsUsing = "Browser Only"; Break}
                                            Default                                                 {$SecureGatewayLaunchSessionsUsing = "Unable to determine Launch sessions using: $($SecureGatewayDefaults.LaunchMethod)"; Break}
        }                                   }
        If($Text)                                  
                                    Switch ($SecureGatewayDefaults.FileTransferMode)
        {                                   {
                Line 1 "CPU Optimization"                                           "Bidirectional"         {$SecureGatewayFileTransferMode = "Bidirectional"; Break}
                                            "Disabled"                      {$SecureGatewayFileTransferMode = "Disabled"; Break}
                                            "ClientToServer"        {$SecureGatewayFileTransferMode = "Client to server only"; Break}
                                            "ServerToClient"        {$SecureGatewayFileTransferMode = "Server to client only"; Break}
                                            Default                         {$SecureGatewayFileTransferMode = "Unable to determine File Transfer mode: $($SecureGatewayDefaults.FileTransferMode)"; Break}
        }                                   }
        If($HTML)    
                                    Switch ($SecureGatewayDefaults.ClipboardDirection)
        {                                   {
                WriteHTMLLine 2 0 "CPU Optimization"                                           "Bidirectional"         {$SecureGatewayClipboardTransferMode = "Bidirectional"; Break}
                                            "Disabled"                      {$SecureGatewayClipboardTransferMode = "Disabled"; Break}
                                            "ClientToServer"        {$SecureGatewayClipboardTransferMode = "Client to server only"; Break}
                                            "ServerToClient"        {$SecureGatewayClipboardTransferMode = "Server to client only"; Break}
                                            Default                         {$SecureGatewayClipboardTransferMode = "Unable to determine Clipboard mode: $($SecureGatewayDefaults.ClipboardDirection)"; Break}
        }                                   }
     
                                    $SecureGatewayAllowLaunchMethod          = $SecureGateway.AllowLaunchMethod.ToString()
                                    $SecureGatewayAllowAppsInNewTab          = $SecureGateway.AllowAppsInNewTab.ToString()
                                    $SecureGatewayUsePreWin2000LoginFormat   = $SecureGateway.UsePreWin2000LoginFormat.ToString()
                                    $SecureGatewayAllowEmbed                 = $SecureGateway.AllowEmbed.ToString()
                                    $SecureGatewayAllowFileTransfer          = $SecureGateway.AllowFileTransfer
                                    $SecureGatewayAllowClipboard             = $SecureGateway.AllowClipboard
                                    $SecureGatewayAllowCORS                  = $SecureGateway.AllowCORS
                                    $SecureGatewayAllowedDomainsForCORS      = $SecureGateway.AllowedDomainsForCORS
                                    $SecureGatewayBrowserCacheTimeInMonths   = $SecureGateway.BrowserCacheTimeInMonths
                                    $SecureGatewayEnableAlternateNLBHostname = $SecureGateway.EnableAlternateNLBHost.ToString()
                                    $SecureGatewayAlternameNLBHostname       = $SecureGateway.AlternateNLBHost
                                    $SecureGatewayEnableAlternateNLBPort     = $SecureGateway.EnableAlternateNLBPort.ToString()
                                    $SecureGatewayAlternateNLBPort           = $SecureGateway.AlternateNLBPort.ToString()
                            }
                                  
        If($MSWord -or $PDF)                           If($MSWord -or $PDF)
        {                           {
                $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                $ScriptInformation.Add(@{Data = "Enable CPU Optimization"; Value = $RASCPUSettings.EnableCPUOptimization.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultUserPortalSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable User Portal"; Value = $SecureGatewayEnableUserPortalClient; }) > $Null
                $ScriptInformation.Add(@{Data = "Start"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Client"; Value = ""; }) > $Null
                $ScriptInformation.Add(@{Data = "     Total CPU usage exceeds"; Value = "$($RASCPUSettings.StartUsage) %"; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $SecureGatewayLaunchSessionsUsing; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $SecureGatewayAllowLaunchMethod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $SecureGatewayAllowAppsInNewTab; }) > $Null
                $ScriptInformation.Add(@{Data = "CPU Conditions"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $SecureGatewayUsePreWin2000LoginFormat; }) > $Null
                $ScriptInformation.Add(@{Data = "     Critical - CPU usage by process exceeds"; Value = "$($RASCPUSettings.CriticalUsage) %"; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow embedding of User Portal into other web pages"; Value = $SecureGatewayAllowEmbed; }) > $Null
                $ScriptInformation.Add(@{Data = "     Idle - CPU usage by process exceeds"; Value = "$($RASCPUSettings.IdleUsage) %"; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $SecureGatewayAllowFileTransfer.ToString(); }) > $Null
                                    If($SecureGatewayAllowFileTransfer)
                                    {
                $ScriptInformation.Add(@{Data = "Exclusions"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Direction"; Value = $SecureGatewayFileTransferMode; }) > $Null
                                    }
                $ScriptInformation.Add(@{Data = "     Processes that will be excluded from CPU Optimization"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $SecureGatewayAllowClipboard.ToString(); }) > $Null
                                                  If($SecureGatewayAllowClipboard)
                If($RASCPUSettings.CPUExcludeList.Count -eq 0)    
                {                                   {
                        $ScriptInformation.Add(@{Data = "          Processes to exclude"; Value = "None"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Clipboard Redirection"; Value = $SecureGatewayClipboardTransferMode; }) > $Null
                }                                   }
                Else                                   $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $SecureGatewayAllowCORS.ToString(); }) > $Null
                                    If($SecureGatewayAllowCORS)
                {                                   {
                        $cnt = -1                                           $cnt=-1
                            
                        ForEach($item in $RASCPUSettings.CPUExcludeList)                                           ForEach($Domain in $SecureGatewayAllowedDomainsForCORS)
                        {                                           {
                                $cnt++                                                   $cnt++
                                                                                  
                                If($cnt -eq 0)                                                   If($cnt -eq 0)
                                {                                                   {
                                        $ScriptInformation.Add(@{Data = "          Processes to exclude"; Value = $item; }) > $Null                                                           $ScriptInformation.Add(@{Data = "     Allow domains"; Value = $Domain; }) > $Null
                                }                                                   }
                                Else                                                   Else
                                {                                                   {
                                        $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = $Domain; }) > $Null
                                }                                                   }
                        }                                           }
                                            $ScriptInformation.Add(@{Data = "     Browser cache time"; Value = "$($SecureGatewayBrowserCacheTimeInMonths.ToString()) months"; }) > $Null
                }                                   }
 
  <>                                 $ScriptInformation.Add(@{Data = "Network Load Balancer access"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Use alternate hostname"; Value = $SecureGatewayEnableAlternateNLBHostname; }) > $Null
                                    If($SecureGatewayEnableAlternateNLBHostname -eq "True")
                                    {
                                            $ScriptInformation.Add(@{Data = ""; Value = $SecureGatewayAlternameNLBHostname; }) > $Null
                                    }
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASCPUSettings.Replicate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Use alternate port"; Value = $SecureGatewayEnableAlternateNLBPort; }) > $Null
                                    If($SecureGatewayEnableAlternateNLBPort -eq "True")
                                    {
                                            $ScriptInformation.Add(@{Data = ""; Value = $SecureGatewayAlternateNLBPort; }) > $Null
                                    }
 
                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                -Columns Data,Value `                                   -Columns Data,Value `
                -List `                                   -List `
                -Format $wdTableGrid `                                   -Format $wdTableGrid `
                -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                $Table.Columns.Item(1).Width = 275; <>                                 $Table.Columns.Item(1).Width = 200;
                $Table.Columns.Item(2).Width = 150;                                   $Table.Columns.Item(2).Width = 250;
 
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                FindWordDocumentEnd <>                                 FindWordDocumentEnd
                $Table = $Null                                   $Table = $Null
                WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 2 "Enable CPU Optimization`t`t`t`t`t: " $RASCPUSettings.EnableCPUOptimization.ToString()    
                Line 2 "Start"    
                Line 3 "Total CPU usage exceeds`t`t`t`t: " "$($RASCPUSettings.StartUsage) %"                                   Line 3 "Inherit default settings`t`t`t: " $SecureGateway.InheritDefaultUserPortalSettings.ToString()
                Line 2 "CPU Conditions"    
                Line 3 "Critical - CPU usage by process exceeds`t`t: " "$($RASCPUSettings.CriticalUsage) %"                                   Line 3 "Enable User Portal`t`t`t`t: " $SecureGatewayEnableUserPortalClient
                Line 3 "Idle - CPU usage by process exceeds`t`t: " "$($RASCPUSettings.IdleUsage) %"    
                Line 2 "Exclusions"                                   Line 3 "Client" ""
                                    Line 4 "Launch sessions using`t`t`t: " $SecureGatewayLaunchSessionsUsing
                                    Line 4 "Allow user to select a launch method`t: " $SecureGatewayAllowLaunchMethod
                                    Line 4 "Allow opening applications in a new tab`t: " $SecureGatewayAllowAppsInNewTab
                                    Line 4 "Use Pre Windows 2000 login format`t: " $SecureGatewayUsePreWin2000LoginFormat
                Line 3 "Processes that will be excluded from CPU Optimization"                                   Line 4 "Allow embedding of User Portal"
                                    Line 4 "into other web pages`t`t`t: " $SecureGatewayAllowEmbed
                    
                If($RASCPUSettings.CPUExcludeList.Count -eq 0)                                   Line 4 "Allow file transfer command`t`t: " $SecureGatewayAllowFileTransfer.ToString()
                                    If($SecureGateway.AllowFileTransfer)
                {                                   {
                        Line 4 "Processes to exclude`t`t`t: None"                                           Line 5 "Direction`t`t`t: " $SecureGatewayFileTransferMode
                }                                   }
                Else    
                                    Line 4 "Allow clipboard command`t`t`t: " $SecureGatewayAllowClipboard.ToString()
                                    If($SecureGateway.AllowClipboard)
                {                                   {
                                            Line 5 "Clipboard Redirection`t`t: " $SecureGatewayClipboardTransferMode
                                    }
     
                                    Line 4 "Allow cross-origin resource sharing`t: " $SecureGatewayAllowCORS.ToString()
                                    If($SecureGatewayAllowCORS)
                                    {
                        $cnt = -1                                           $cnt=-1
                            
                        ForEach($item in $RASCPUSettings.CPUExcludeList)                                           ForEach($Domain in $SecureGatewayAllowedDomainsForCORS)
                        {                                           {
                                $cnt++                                                   $cnt++
                                                                                  
                                If($cnt -eq 0)                                                   If($cnt -eq 0)
                                {                                                   {
                                        Line 4 "Processes to exclude`t`t`t: " $item                                                           Line 7 "Allow domains   : " $Domain
                                }                                                   }
                                Else                                                   Else
                                {                                                   {
                                        Line 9 "  " $item                                                           Line 9 "  " $Domain
                                }                                                   }
                        }                                           }
                                            Line 6 "Browser cache time      : " "$($SecureGatewayBrowserCacheTimeInMonths.ToString()) months"
                }                                   }
 
  <>                                 Line 3 "Network Load Balancer access" ""
                                    Line 4 "Use alternate hostname`t`t: " $SecureGatewayEnableAlternateNLBHostname
                                    If($SecureGatewayEnableAlternateNLBHostname -eq "True")
                                    {
                                            Line 8 $SecureGatewayAlternameNLBHostname
                                    }
                Line 2 "Settings are replicated to all Sites`t`t`t: " $RASCPUSettings.Replicate.ToString()                                   Line 4 "Use alternate port`t`t: " $SecureGatewayEnableAlternateNLBPort
                                    If($SecureGatewayEnableAlternateNLBPort -eq "True")
                                    {
                                            Line 8 $SecureGatewayAlternateNLBPort
                                    }
                Line 0 ""                                   Line 0 ""
        }                           }
        If($HTML)                           If($HTML)
        {                           {
                $rowdata = @()                                   $rowdata = @()
                $columnHeaders = @("Enable CPU Optimization",($Script:htmlsb),$RASCPUSettings.EnableCPUOptimization.ToString(),$htmlwhite)                                   $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultUserPortalSettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Enable User Portal",($Script:htmlsb),$SecureGatewayEnableUserPortalClient,$htmlwhite))
                $rowdata += @(,("Start",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Client",($Script:htmlsb),"",$htmlwhite))
                $rowdata += @(,("     Total CPU usage exceeds",($Script:htmlsb),"$($RASCPUSettings.StartUsage) %",$htmlwhite))                                   $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$SecureGatewayLaunchSessionsUsing,$htmlwhite))
                                    $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$SecureGatewayAllowLaunchMethod,$htmlwhite))
                                    $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb),$SecureGatewayAllowAppsInNewTab,$htmlwhite))
                $rowdata += @(,("CPU Conditions",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb),$SecureGatewayUsePreWin2000LoginFormat,$htmlwhite))
                $rowdata += @(,("     Critical - CPU usage by process exceeds",($Script:htmlsb),"$($RASCPUSettings.CriticalUsage) %",$htmlwhite))                                   $rowdata += @(,("     Allow embedding of User Portal into other web pages",($Script:htmlsb),$SecureGatewayAllowEmbed,$htmlwhite))
     
                $rowdata += @(,("     Idle - CPU usage by process exceeds",($Script:htmlsb),"$($RASCPUSettings.IdleUsage) %",$htmlwhite))                                   $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$SecureGatewayAllowFileTransfer.ToString(),$htmlwhite))
                                    If($SecureGateway.AllowFileTransfer)
                                    {
                $rowdata += @(,("Exclusions",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("          Direction",($Script:htmlsb),$SecureGatewayFileTransferMode,$htmlwhite))
                                    }
     
                $rowdata += @(,("     Processes that will be excluded from CPU Optimization",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$SecureGatewayAllowClipboard.ToString(),$htmlwhite))
                                                  If($SecureGateway.AllowClipboard)
                If($RASCPUSettings.CPUExcludeList.Count -eq 0)    
                {                                   {
                        $rowdata += @(,("          Processes to exclude",($Script:htmlsb),"None",$htmlwhite))                                           $rowdata += @(,("          Clipboard Redirection",($Script:htmlsb),$SecureGatewayClipboardTransferMode,$htmlwhite))
                }                                   }
                Else    
                                    $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$SecureGatewayAllowCORS.ToString(),$htmlwhite))
                                    If($SecureGatewayAllowCORS)
                {                                   {
                        $cnt = -1                                           $cnt=-1
                            
                        ForEach($item in $RASCPUSettings.CPUExcludeList)                                           ForEach($Domain in $SecureGatewayAllowedDomainsForCORS)
                        {                                           {
                                $cnt++                                                   $cnt++
                                                                                  
                                If($cnt -eq 0)                                                   If($cnt -eq 0)
                                {                                                   {
                                        $rowdata += @(,("          Processes to exclude",($Script:htmlsb),$item,$htmlwhite))                                                           $rowdata += @(,("     Allow domains",($Script:htmlsb),$Domain,$htmlwhite))
                                }                                                   }
                                Else                                                   Else
                                {                                                   {
                                        $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),$Domain,$htmlwhite))
                                }                                                   }
                        }                                           }
                                            $rowdata += @(,("     Browser cache time",($Script:htmlsb),"$($SecureGatewayBrowserCacheTimeInMonths.ToString()) months",$htmlwhite))
                }                                   }
 
  <>                                 $rowdata += @(,("Network Load Balancer access",($Script:htmlsb),"",$htmlwhite))
                $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASCPUSettings.Replicate.ToString(),$htmlwhite))                                   $rowdata += @(,("     Use alternate hostname",($Script:htmlsb),$SecureGatewayEnableAlternateNLBHostname,$htmlwhite))
                $msg = ""                                   If($SecureGatewayEnableAlternateNLBHostname -eq "True")
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
        }                                   {
                                            $rowdata += @(,("",($Script:htmlsb),$SecureGatewayAlternameNLBHostname,$htmlwhite))
}                                   }
#endregion                                   $rowdata += @(,("     Use alternate port",($Script:htmlsb),$SecureGatewayEnableAlternateNLBPort,$htmlwhite))
                                    If($SecureGatewayEnableAlternateNLBPort -eq "True")
#region process publishing    
Function ListFolder($folder, $spaces)     
{                                   {
        #function provided 23-July-2020 by Ian Sant of Parallels                                           $rowdata += @(,("",($Script:htmlsb),$SecureGatewayAlternateNLBPort,$htmlwhite))
        #list published items in the order they appear in the console    
        #modified 24-July-2020 by Webster to make it work with this script    
        $prevId = 0    
     
        Do    
        {    
                $item = $Script:AllItems | Where-Object {($_.ParentId -eq $folder) -and ($_.PreviousId -eq $prevId)}    
                If ($Null -eq $item) {    
                        Return    
                }                                   }
 
                #Write-Host $spaces $item.Name <>                                 $msg = "User Portal"
                $Script:OrderedItems.Add($item) >$Null                                   $columnWidths = @("300","275")
                If ($item.Type -eq "Folder") {                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                        $newspaces = $spaces + "   "                                   WriteHTMLLine 0 0 ""
                        ListFolder $item.Id $newspaces    
                }                           }
                $prevId = $item.Id    
        } While ($true)     
}    
                            #Wyse
Function ProcessPublishing    
{    
        Param([object]$Site)    
            
        Write-Verbose "$(Get-Date -Format G): Processing Publishing"    
            
        OutputPublishingSectionPage $Site.Name    
 
        Write-Verbose "$(Get-Date -Format G): `tProcessing Publishing" <>  
            
        $results = Get-RASPubItem -SiteId $Site.Id -EA 0 4>$Null    
                    
        If(!($?))    
        {    
                Write-Warning "    
                `n    
                Unable to retrieve Publishing information for Site $($Site.Name)    
                "    
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Publishing information for Site $($Site.Name)"                                   WriteWordLine 4 0 "Wyse"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve Publishing information for Site $($Site.Name)"                                   Line 2 "Wyse"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Publishing information for Site $($Site.Name)"    
                }                                   #Nothing
        }                           }
        ElseIf($? -and $null -eq $results)    
        {                           
                Write-Host "    
                No Publishing information was found for Site $($Site.Name)                           If($SecureGateway.InheritDefaultWyseSettings)
                " -ForegroundColor White    
                If($MSWord -or $PDF)    
                {                           {
                        WriteWordLine 2 0 "No Publishing information was found for Site $($Site.Name)"                                   #do we inherit site defaults?
                                    #yes we do, get the default settings for the Site
                                    #use the Site default settings
                }    
                If($Text)                                   $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $SecureGatewayDefaults)
                {                                   {
                        Line 0 "No Publishing information was found for Site $($Site.Name)"                                           $SecureGatewayEnableWyse          = $SecureGatewayDefaults.EnableWyseSupport.ToString()
                                            $SecureGatewayDisableWyseCertWarn = $SecureGatewayDefaults.DisableWyseCertWarn.ToString()
                }                                   }
                If($HTML)                                   Else
                {                                   {
                        WriteHTMLLine 2 0 "No Publishing information was found for Site $($Site.Name)"                                           #unable to retrieve default, use built-in default values
                                            $SecureGatewayEnableWyse          = "True"
                                            $SecureGatewayDisableWyseCertWarn = "False"
                }                                   }
        }                           }
        Else                           Else
        {                           {
                $Script:OrderedItems = New-Object System.Collections.ArrayList                                   #we don't inherit settings
                $Script:AllItems = $results                                   #get the settings configured for this GW
                ListFolder 0 ""                                   $SecureGatewayEnableWyse          = $SecureGateway.EnableWyseSupport.ToString()
                OutputPublishingSettings $Script:OrderedItems $Site.Id $Site.Name                                   $SecureGatewayDisableWyseCertWarn = $SecureGateway.DisableWyseCertWarn.ToString()
        }                           }
}    
     
Function OutputPublishingSectionPage    
{    
        Param([string] $SiteName)    
                                  
        If($MSWord -or $PDF)                           If($MSWord -or $PDF)
        {                           {
                $Script:Selection.InsertNewPage()                                   $ScriptInformation = New-Object System.Collections.ArrayList
                WriteWordLine 1 0 "Publishing for Site $($SiteName)"                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultWyseSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable Wyse ThinOS Support"; Value = $SecureGatewayEnableWyse; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Do not warn if server certificate is not verified"; Value = $SecureGatewayDisableWyseCertWarn; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
        }                           }
        If($Text)                           If($Text)
        {                           {
                Line 0 "Publishing for Site $($SiteName)"                                   Line 3 "Inherit default settings`t`t`t : " $SecureGateway.InheritDefaultWyseSettings.ToString()
                                    Line 3 "Enable Wyse ThinOS Support`t`t`t : " $SecureGatewayEnableWyse
                                    Line 3 "Do not warn if server certificate is not verified: " $SecureGatewayDisableWyseCertWarn
                                    Line 0 ""
        }                           }
        If($HTML)                           If($HTML)
        {                           {
                WriteHTMLLine 1 0 "Publishing for Site $($SiteName)"                                   $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultWyseSettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Enable Wyse ThinOS Support",($Script:htmlsb),$SecureGatewayEnableWyse,$htmlwhite))
                                    $rowdata += @(,("Do not warn if server certificate is not verified",($Script:htmlsb),$SecureGatewayDisableWyseCertWarn,$htmlwhite))
        }    
                                    $msg = "Wyse"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
}                           }
 
Function OutputPublishingSettings <>  
{    
        Param([object] $PubItems, [uint32] $SiteId, [string] $xSiteName)    
            
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing"    
            
        <#    
        Folder    
        PCApp    
        PCDesktop    
        RDSApp    
        RDSDesktop    
        VDIApp    
        VDIDesktop    
        WVDApp    
        WVDDesktop    
        #>    
     
        #Get the published items default settings    
        Write-Verbose "$(Get-Date -Format G): `t`t`tRetrieve Publishing Default Site Settings for Site $xSiteName"    
        $results = Get-RASPubDefaultSettings -SiteId $SiteId -EA 0 4>$Null    
            
        If(!$?)    
        {    
                Write-Host "    
                Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults    
                " -ForegroundColor White    
                <#    
                StartPath                     : RAS Remote Desktops & Applications\%Groups%    
                CreateShortcutOnDesktop       : False    
                CreateShortcutInStartFolder   : True    
                CreateShortcutInStartUpFolder : False    
                ReplicateShortcutSettings     : False    
                ReplicateDisplaySettings      : False    
                WaitForPrinters               : False    
                StartMaximized                : True    
                WaitForPrintersTimeout        : 20    
                ColorDepth                    : ClientSpecified    
                DisableSessionSharing         : False    
                OneInstancePerUser            : False    
                ConCurrentLicenses            : 0    
                LicenseLimitNotify            : WarnUserAndNoStart    
                ReplicateLicenseSettings      : False    
                #>    
                    
                #Shortcuts tab                           #Security
                $DefaultCreateShortcutOnDesktop       = "False"    
                $DefaultCreateShortcutInStartFolder   = "True"    
                $DefaultStartPath                     = "RAS Remote Desktops & Applications\%Groups%"    
                $DefaultCreateShortcutInStartUpFolder = "False"    
                $DefaultReplicateShortcutSettings     = "False"    
                                          
                #License tab    
                $DefaultDisableSessionSharing         = "False"    
                $DefaultOneInstancePerUser            = "False"    
                $DefaultConCurrentLicenses            = "Unlimited"    
                $DefaultLicenseLimitNotify            = "Warn user and do not start"    
                $DefaultReplicateLicenseSettings      = "False"    
     
                #Display tab    
                $DefaultWaitForPrinters               = "False"    
                $DefaultWaitForPrintersTimeout        = "20"    
                $DefaultColorDepth                    = "Client Specified"    
                $DefaultStartMaximized                = "True"    
                $DefaultReplicateDisplaySettings      = "False"    
     
                If($MSWord -or $PDF)                           If($MSWord -or $PDF)
                {                           {
                        WriteWordLine 0 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"                                   WriteWordLine 4 0 "Security"
                }                           }
                If($Text)                           If($Text)
                {                           {
                        Line 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"                                   Line 2 "Security"
                }                           }
                If($HTML)                           If($HTML)
                {                           {
                        WriteHTMLLine 0 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"    
                }                                   #Nothing
        }                           }
        Else    
        {                           
                #Shortcuts tab    
                $DefaultCreateShortcutOnDesktop       = $results.CreateShortcutOnDesktop.ToString()          
                $DefaultCreateShortcutInStartFolder   = $results.CreateShortcutInStartFolder.ToString()    
                $DefaultStartPath                     = $results.StartPath                        
                $DefaultCreateShortcutInStartUpFolder = $results.CreateShortcutInStartUpFolder.ToString()    
                $DefaultReplicateShortcutSettings     = $results.ReplicateShortcutSettings.ToString()                           If($SecureGateway.InheritDefaultSecuritySettings)
     
                #License tab    
                $DefaultDisableSessionSharing         = $results.DisableSessionSharing.ToString()        
                $DefaultOneInstancePerUser            = $results.OneInstancePerUser.ToString()    
                If($results.ConCurrentLicenses -eq 0)    
                {                           {
                        $DefaultConCurrentLicenses        = "Unlimited"                                   #do we inherit site defaults?
                                    #yes we do, get the default settings for the Site
                                    #use the Site default settings
                }    
                                    $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                Else                                  
                                    If($? -and $Null -ne $SecureGatewayDefaults)
                {                                   {
                        $DefaultConCurrentLicenses        = $results.ConCurrentLicenses.ToString()                                               If($SecureGatewayDefaults.SecurityMode -eq "AllowAllExcept")
                }    
                     
                Switch ($results.LicenseLimitNotify)    
                {                                           {
                        "WarnUserAndNoStart"            {$DefaultLicenseLimitNotify = "Warn user and do not start"; Break}                                                   $SecureGatewayAllow = "AllowAllExcept"
                        "WarnUserAndStart"                      {$DefaultLicenseLimitNotify = "Warn user and start"; Break}                                                   $MACAddresses = @()
                        "NotifyAdminAndStart"           {$DefaultLicenseLimitNotify = "Notify administrator and start"; Break}    
                        "NotifyUserAdminAndStart"       {$DefaultLicenseLimitNotify = "Notify user, administrator and start"; Break}    
                        "NotifyUserAdminAndNoStart"     {$DefaultLicenseLimitNotify = "Notify user, administrator and do not start"; Break}    
                        Default                                         {$DefaultLicenseLimitNotify = "Unable to determine If limit is eceeded: $($results.LicenseLimitNotify)"; Break}    
                }    
                    
                $DefaultReplicateLicenseSettings      = $results.ReplicateLicenseSettings.ToString()    
     
                #Display tab    
                $DefaultWaitForPrinters               = $results.WaitForPrinters.ToString()    
                $DefaultWaitForPrintersTimeout        = $results.WaitForPrintersTimeout.ToString()    
                Switch ($results.ColorDepth)                                                   ForEach($Item in $SecureGatewayDefaults.MACAllowExcept)
                {                                                   {
                        "Colors8Bit"            {$DefaultColorDepth = "256 Colors"; Break}                                                           $MACAddresses += $Item
                        "Colors15Bit"           {$DefaultColorDepth = "High Color (15 bit)"; Break}    
                        "Colors16Bit"           {$DefaultColorDepth = "High Color (16 bit)"; Break}    
                        "Colors24Bit"           {$DefaultColorDepth = "True Color (24 bit)"; Break}    
                        "Colors32Bit"           {$DefaultColorDepth = "Highest Quality (32 bit)"; Break}    
                        "ClientSpecified"       {$DefaultColorDepth = "Client Specified"; Break}    
                        Default                         {$DefaultColorDepth = "Unable to determine Color Depth: $($PubItem.ColorDepth)"; Break}    
                }                                                   }
                $DefaultStartMaximized                = $results.StartMaximized.ToString()       
                $DefaultReplicateDisplaySettings      = $results.ReplicateDisplaySettings.ToString()    
        }                                           }
            
        ForEach($PubItem in $PubItems)    
        {    
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tOutput $($PubItem.Name)"    
                                            Else
                If(ValidObject $PubItem WinType)    
                {                                           {
                        Switch ($PubItem.WinType)                                                   $SecureGatewayAllow = "AllowOnly"
                                                    $MACAddresses = @()
                                                    ForEach($Item in $SecureGatewayDefaults.MACAllowOnly)
                        {                                                   {
                                "Normal"        {$WinType = "Normal Window"; Break}                                                           $MACAddresses += $Item
                                "Maximized"     {$WinType = "Maximized"; Break}    
                                "Minimized"     {$WinType = "Minimized"; Break}    
                                Default         {$WinType = "Unable to determine window Run type: $($PubItem.WinType)"; Break}    
                        }                                                   }
                }                                           }
     
                If($PubItem.PreferredRoutingEnabled)    
                {    
                        $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null    
                            
                        If(!$? -or $Null -eq $Results)    
                        {    
                                $PreferredRouting = ""    
                        }                                   }
                        Else                                   Else
                        {                                   {
                                $PreferredRouting = ""                                           #unable to retrieve default, use built-in default values
                                            $SecureGatewayAllow = "AllowAllExcept"
                                            $MACAddresses = @()
                        }                                   }
                }                           }
                Else                           Else
                {                           {
                        $PreRouting = ""                                   #we don't inherit settings
                }                                   #get the settings configured for this GW
                                                  If($SecureGateway.SecurityMode -eq "AllowAllExcept")
                If($MSWord -or $PDF)    
                {                                   {
                        WriteWordLine 2 0 $PubItem.Name                                           $SecureGatewayAllow = "AllowAllExcept"
                }                                           $MACAddresses = @()
                If($Text)                                           ForEach($Item in $SecureGateway.MACAllowExcept)
                {                                           {
                        Line 1 $PubItem.Name                                                   $MACAddresses += $Item
                }                                           }
                If($HTML)    
                {    
                        WriteHTMLLine 2 0 $PubItem.Name    
                }                                   }
                                          Else
                If($PubItem.Type -eq "Folder")    
                {                                   {
                        If($MSWord -or $PDF)                                           $SecureGatewayAllow = "AllowOnly"
                                            $MACAddresses = @()
                                            ForEach($Item in $SecureGateway.MACAllowOnly)
                        {                                           {
                                WriteWordLine 3 0 "Information"                                                   $MACAddresses += $Item
                        }                                           }
                        If($Text)    
                        {    
                                Line 2 "Information"    
                        }                                   }
                        If($HTML)    
                        {    
                                WriteHTMLLine 3 0 "Information"    
 
                                $ScriptInformation.Add(@{Data = "Folder"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultSecuritySettings.ToString(); }) > $Null
                                                                  If($SecureGatewayAllow -eq "AllowAllExcept")
                                If($PubItem.AdminOnly -eq $True)    
 
                                        $ScriptInformation.Add(@{Data = "Use for administrative purposes"; Value = ""; }) > $Null <>  
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Allow all except"; Value = ""; }) > $Null
 
  <>  
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else                                   Else
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
 
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null <>  
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null                                           $ScriptInformation.Add(@{Data = "Allow only"; Value = ""; }) > $Null
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
 
  +-  
 
                                ForEach($Site in $PubItem.PublishToSite) <>                                 ForEach($Item in $MACAddresses)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
                                            
 
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "MAC Address"; Value = $Item; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                         }
                                WriteWordLine 3 0 "Sites"                           If($Text)
                                $ScriptInformation = New-Object System.Collections.ArrayList                           {
                                    Line 3 "Inherit default settings`t`t: " $SecureGateway.InheritDefaultSecuritySettings.ToString()
                                    If($SecureGatewayAllow -eq "AllowAllExcept")
                                    {
                                            Line 3 "Allow all except"
                                    }
                                    Else
                                    {
                                            Line 3 "Allow only"
                                    }
 
                                ForEach($Site in $PubItem.PublishToSite) <>                                 ForEach($Item in $MACAddresses)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
                                            
 
  <>                                                 Line 3 "MAC Address`t`t`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 8 "  " $Item
                                            }
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null                                   $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultSecuritySettings.ToString(),$htmlwhite)
                                    If($SecureGatewayAllow -eq "AllowAllExcept")
                                    {
                                            $rowdata += @(,("Allow all except",($Script:htmlsb),"",$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Allow only",($Script:htmlsb),"",$htmlwhite))
                                    }
                                    $cnt =-1
                                    ForEach($Item in $MACAddresses)
                                    {
                                            $cnt++
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("MAC Address",($Script:htmlsb),$Item,$htmlwhite))
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
 
  -+  
                                    $msg = "Security"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #Web
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Web"
                            }
                            If($Text)
                            {
                                    Line 2 "Web"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($SecureGateway.InheritDefaultWebSettings)
                            {
                                    #do we inherit site defaults?
                                    #yes we do, get the default settings for the Site
                                    #use the Site default settings
     
                                    $SecureGatewayDefaults = Get-RASGatewayDefaultSettings -SiteId $Site.Id -EA 0 4>$Null
                                    
                                    If($? -and $Null -ne $SecureGatewayDefaults)
                                    {
                                            $SecureGatewayDefaultURL = $SecureGatewayDefaults.WebRequestsURL
                                            $SecureGatewayWebCookie = $SecureGatewayDefaults.WebCookie
                                    }
                                    Else
                                    {
                                            #unable to retrieve default, use built-in default values
                                            $SecureGatewayDefaultURL = "https://%hostname%/RASHTML5Gateway"
                                            $SecureGatewayWebCookie = "ASP.NET_SessionId"
                                    }
                            }
                            Else
                            {
                                    #we don't inherit settings
                                    #get the settings configured for this GW
                                    $SecureGatewayDefaultURL = $SecureGateway.WebRequestsURL
                                    $SecureGatewayWebCookie = $SecureGateway.WebCookie
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $SecureGateway.InheritDefaultWebSettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Default URL"; Value = $SecureGatewayDefaultURL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Web cookie"; Value = $SecureGatewayWebCookie; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Use a secure web cookie"; Value = $SecureGateway.UseSecureWebCookie.ToString(); }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 3 "Inherit default settings`t`t: " $SecureGateway.InheritDefaultWebSettings.ToString()
                                    Line 3 "Default URL`t`t`t`t: " $SecureGatewayDefaultURL
                                    Line 3 "Web cookie`t`t`t`t: " $SecureGatewayWebCookie
                                    Line 3 "Use a secure web cookie`t`t`t: " $SecureGateway.UseSecureWebCookie.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$SecureGateway.InheritDefaultWebSettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Default URL",($Script:htmlsb),$SecureGatewayDefaultURL,$htmlwhite))
                                    $rowdata += @(,("Web cookie",($Script:htmlsb),$SecureGatewayWebCookie,$htmlwhite))
                                    $rowdata += @(,("Use a secure web cookie",($Script:htmlsb),$SecureGateway.UseSecureWebCookie.ToString(),$htmlwhite))
 
  <>                                 $msg = "Web"
                                    $columnWidths = @("300","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
     
            If($MSWord -or $PDF)
            {
                                WriteWordLine 3 0 "Folder"                   WriteWordLine 2 0 "Connection Brokers"
            }
            If($Text)
            {
                    Line 1 "Connection Brokers"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Connection Brokers"
            }
     
            $ConnectionBrokers = Get-RASBroker -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Connection Brokers for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Connection Brokers for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $ConnectionBrokers)
            {
                    Write-Host "
                    No Connection Brokers retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Connection Brokers retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Connection Brokers retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Connection Brokers"
                    ForEach($ConnectionBroker in $ConnectionBrokers)
                    {
                            $ConnectionBrokerStatus = Get-RASBrokerStatus -Id $ConnectionBroker.Id -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    Write-Warning "
                                    `n
                                    Unable to retrieve Status for Connection Broker $($ConnectionBroker.Id)`
                                    "
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "Unable to retrieve Status for Connection Broker $($ConnectionBroker.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "Unable to retrieve Status for Connection Broker $($ConnectionBroker.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "Unable to retrieve Status for Connection Broker $($ConnectionBroker.Id)"
                                    }
                            }
                            ElseIf($? -and $Null -eq $ConnectionBrokerStatus)
                            {
                                    Write-Host "
                                    No Status retrieved for Connection Broker $($ConnectionBroker.Id)`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No Status retrieved for Connection Broker $($ConnectionBroker.Id)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No Status retrieved for Connection Broker $($ConnectionBroker.Id)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No Status retrieved for Connection Broker $($ConnectionBroker.Id)"
                                    }
                            }
                            Else
                            {
                                    If($ConnectionBroker.Standby -eq $False)
                                    {
                                            $ConnectionBrokerPriority = "Master"
                                    }
                                    Else
                                    {
                                            $ConnectionBrokerPriority = "Standby"
                                    }
     
                                    $ConnectionBrokerStatusAgentState = GetRASStatus $ConnectionBrokerStatus.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 3 0 "Connection Broker $($ConnectionBroker.Server)"
                                $ScriptInformation = New-Object System.Collections.ArrayList                                           $ScriptInformation = New-Object System.Collections.ArrayList
                                            $ScriptInformation.Add(@{Data = "Server"; Value = $ConnectionBroker.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "Folder Name"; Value = $PubItem.Name; }) > $Null                                           $ScriptInformation.Add(@{Data = "Enabled"; Value = $ConnectionBroker.Enabled.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null                                           $ScriptInformation.Add(@{Data = "Priority"; Value = $ConnectionBrokerPriority; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Status"; Value = $ConnectionBrokerStatusAgentState; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Log level"; Value = $ConnectionBrokerStatus.LogLevel; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Last modification by"; Value = $ConnectionBroker.AdminLastMod; }) > $Null
                                $ScriptInformation.Add(@{Data = "Use for administrative purposes"; Value = $PubItem.AdminOnly.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Modified on"; Value = $ConnectionBroker.TimeLastMod.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created by"; Value = $ConnectionBroker.AdminCreate; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Created on"; Value = $ConnectionBroker.TimeCreate.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "ID"; Value = $ConnectionBroker.Id.ToString(); }) > $Null
 
                                $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                         $Table = AddWordTable -Hashtable $ScriptInformation `
                                -Columns Data,Value `                                           -Columns Data,Value `
                                -List `                                           -List `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                                $Table.Columns.Item(1).Width = 200; <>                                         $Table.Columns.Item(1).Width = 200;
                                $Table.Columns.Item(2).Width = 300;                                           $Table.Columns.Item(2).Width = 250;
 
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                         $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
     
                                OutputPubItemFilters $PubItem "MSWordPDF"    
                        }                                   }
                        If($Text)                                   If($Text)
                        {                                   {
                                Line 3 "Folder`t`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"                                           Line 2 "Connection Broker $($ConnectionBroker.Server)"
                                            Line 3 "Server`t`t`t: " $ConnectionBroker.Server
                                            Line 3 "Enabled`t`t`t: " $ConnectionBroker.Enabled.ToString()
                                            Line 3 "Priority`t`t: " $ConnectionBrokerPriority
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description                                           Line 3 "Status`t`t`t: " $ConnectionBrokerStatusAgentState
                                            Line 3 "Log level`t`t: " $ConnectionBrokerStatus.LogLevel
                                Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod                                           Line 3 "Last modification by`t: " $ConnectionBroker.AdminLastMod
                                Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()                                           Line 3 "Modified on`t`t: " $ConnectionBroker.TimeLastMod.ToString()
                                Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate                                           Line 3 "Created by`t`t: " $ConnectionBroker.AdminCreate
                                Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()                                           Line 3 "Created on`t`t: " $ConnectionBroker.TimeCreate.ToString()
                                    
                                If($PubItem.AdminOnly -eq $True)    
                                {    
                                        Line 3 "Use for administrative purposes"    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 "Own Filters"    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        Line 3 " User filtering is enabled"    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                Line 10 "  " $Item.Account    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        Line 3 " IP filtering is enabled"    
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        Line 3 " Client filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        Line 3 " MAC filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        Line 3 " Gateway filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 " Client device operating system filtering is enabled"    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                Line 10 "  Android"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                Line 10 "  ChromeApp"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                Line 10 "  iOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                Line 10 "  Linux"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                Line 10 "  macOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                Line 10 "  RAS Web Portal"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                Line 10 "  Windows"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                Line 10 "  Wyse"    
                                        }    
                                        Line 0 ""    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName    
                                        }    
                                        Else    
                                        {    
                                                Line 10 $SiteName    
                                        }    
                                }    
                                Line 0 ""    
     
                                Line 2 Sites    
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "This published item will be available from the following Sites: " $SiteName    
                                        }    
                                        Else    
                                        {    
                                                Line 10 "  " $SiteName    
                                        }    
                                }    
                                    
                                Line 2 "Folder"    
                                Line 3 "Folder Name`t`t`t`t`t`t: " $PubItem.Name    
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description    
                                Line 3 "Use for administrative purposest`t`t`t: " $PubItem.AdminOnly.ToString()                                           Line 3 "ID`t`t`t: " $ConnectionBroker.Id.ToString()
                                Line 0 ""                                           Line 0 ""
                                    
                                OutputPubItemFilters $PubItem "Text"    
                        }                                   }
                        If($HTML)                                   If($HTML)
                        {                                   {
                                            WriteHTMLLine 3 0 "Connection Broker $($ConnectionBroker.Server)"
                                $rowdata = @()                                           $rowdata = @()
     
                                $columnHeaders = @("Folder",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))                                           $columnHeaders = @("Server",($Script:htmlsb),$ConnectionBroker.Server,$htmlwhite)
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))                                           $rowdata += @(,("Enabled",($Script:htmlsb),$ConnectionBroker.Enabled.ToString(),$htmlwhite))
                                    
                                If($PubItem.AdminOnly -eq $True)    
                                {    
                                        $rowdata += @(,("Use for administrative purposes",($Script:htmlsb), "",$htmlwhite))                                           $rowdata += @(,("Priority",($Script:htmlsb),$ConnectionBrokerPriority,$htmlwhite))
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Status",($Script:htmlsb),$ConnectionBrokerStatusAgentState,$htmlwhite))
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Log level",($Script:htmlsb),$ConnectionBrokerStatus.LogLevel,$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Last modification by",($Script:htmlsb), $ConnectionBroker.AdminLastMod,$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Modified on",($Script:htmlsb), $ConnectionBroker.TimeLastMod.ToString(),$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Created by",($Script:htmlsb), $ConnectionBroker.AdminCreate,$htmlwhite))
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Folder"    
                                $rowdata = @()    
     
                                $columnHeaders = @("Folder",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))                                           $rowdata += @(,("Created on",($Script:htmlsb), $ConnectionBroker.TimeCreate.ToString(),$htmlwhite))
                                $rowdata += @(,("Use for administrative purposes",($Script:htmlsb),$PubItem.AdminOnly.ToString(),$htmlwhite))                                           $rowdata += @(,("ID",($Script:htmlsb),$ConnectionBroker.Id.ToString(),$htmlwhite))
 
                                $msg = "" <>                                         $msg = ""
                                $columnWidths = @("200","300")                                           $columnWidths = @("200","275")
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                           FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteHTMLLine 0 0 ""                                           WriteHTMLLine 0 0 ""
     
                                OutputPubItemFilters $PubItem "HTML"    
                        }                                   }
                }                           }
                ElseIf($PubItem.Type -eq "PCApp")    
                {                           
 
                                WriteWordLine 3 0 "Information" <>                                 WriteWordLine 4 0 "Properties"
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Remote PC Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null    
     
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null    
                                }                           }
                                    
                                $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null    
                                    
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
                            If($Text)
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {                           {
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null                                   Line 2 "Properties"
                                }                           }
                            If($HTML)
                                If($PubItem.UserFilterEnabled)    
                                {                           {
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
                                    #Nothing
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }                           }
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null    
                                                                  
                                        ForEach($item in $PubItem.AllowedClients)                           If($MSWord -or $PDF)
                                        {                           {
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   $ScriptInformation = New-Object System.Collections.ArrayList
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Enable Server in Site"; Value = $ConnectionBroker.Enabled.ToString(); }) > $Null
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   $ScriptInformation.Add(@{Data = "Server"; Value = $ConnectionBroker.Server; }) > $Null
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                   $ScriptInformation.Add(@{Data = "IP"; Value = $ConnectionBroker.IP; }) > $Null
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Alternative IPs"; Value = $ConnectionBroker.AlternativeIPs; }) > $Null
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Description"; Value = $ConnectionBroker.Description; }) > $Null
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Standby"; Value = $ConnectionBroker.Standby.ToString(); }) > $Null
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null    
                                        }    
                                }    
 
  <>                                 $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Enable Server in Site`t: " $ConnectionBroker.Enabled.ToString()
                                    Line 3 "Server`t`t`t: " $ConnectionBroker.Server
                                    Line 3 "IP`t`t`t: " $ConnectionBroker.IP
                                    Line 3 "Alternative IPs`t`t: " $ConnectionBroker.AlternativeIPs
                                    Line 3 "Description`t`t: " $ConnectionBroker.Description
                                    Line 3 "Standby`t`t`t: " $ConnectionBroker.Standby.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Enable Server in Site",($Script:htmlsb),$ConnectionBroker.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Server",($Script:htmlsb),$ConnectionBroker.Server,$htmlwhite))
                                    $rowdata += @(,("IP",($Script:htmlsb),$ConnectionBroker.IP,$htmlwhite))
                                    $rowdata += @(,("Alternative IPs",($Script:htmlsb),$ConnectionBroker.AlternativeIPs,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$ConnectionBroker.Description,$htmlwhite))
                                    $rowdata += @(,("Standby",($Script:htmlsb),$ConnectionBroker.Standby.ToString(),$htmlwhite))
     
                                    $msg = "Properties"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
            
            #Enrollment Servers
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Enrollment Servers"
            }
            If($Text)
            {
                    Line 1 "Enrollment Servers"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Enrollment Servers"
            }
     
            $EnrollmentServers = Get-RASEnrollmentServer -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Enrollment Servers for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Enrollment Servers for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $EnrollmentServers)
            {
                    Write-Host "
                    No Enrollment Servers retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Enrollment Servers retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Enrollment Servers retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Enrollment Servers retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Enrollment Servers"
                    ForEach($EnrollmentServer in $EnrollmentServers)
                    {
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Enrollment Server $($EnrollmentServer.Server)"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $EnrollmentServer.Server; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enabled"; Value = $EnrollmentServer.Enabled.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Status"; Value = "Can't find"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $EnrollmentServer.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Log level"; Value = "Can't find"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $EnrollmentServer.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $EnrollmentServer.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $EnrollmentServer.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $EnrollmentServer.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "ID"; Value = $EnrollmentServer.Id.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                $Table.Columns.Item(2).Width = 300;                                   $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 2 "Enrollment Server $($EnrollmentServer.Server)"
                                    Line 3 "Name`t`t`t: " $EnrollmentServer.Server
                                    Line 3 "Enabled`t`t`t: " $EnrollmentServer.Enabled.ToString()
                                    Line 3 "Status`t`t`t: " "Can't find"
                                    Line 3 "Description`t`t: " $EnrollmentServer.Description
                                    Line 3 "Log level`t`t: " "Can't find"
                                    Line 3 "Last modification by`t: " $EnrollmentServer.AdminLastMod
                                    Line 3 "Modified on`t`t: " $EnrollmentServer.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t: " $EnrollmentServer.AdminCreate
                                    Line 3 "Created on`t`t: " $EnrollmentServer.TimeCreate.ToString()
                                    Line 3 "ID`t`t`t: " $EnrollmentServer.Id.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 3 0 "Enrollment Server $($EnrollmentServer.Server)"
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$EnrollmentServer.Server,$htmlwhite)
                                    $rowdata += @(,("Enabled",($Script:htmlsb),$EnrollmentServer.Enabled.ToString(),$htmlwhite))
                                    $rowdata += @(,("Status",($Script:htmlsb),"Can't find",$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$EnrollmentServer.Description,$htmlwhite))
                                    $rowdata += @(,("Log level",($Script:htmlsb),"Can't find",$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $EnrollmentServer.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $EnrollmentServer.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $EnrollmentServer.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $EnrollmentServer.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("ID",($Script:htmlsb),$EnrollmentServer.Id.ToString(),$htmlwhite))
 
  <>                                 $msg = ""
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                WriteWordLine 3 0 "Sites"                                   WriteWordLine 4 0 "Properties"
                            }
                            If($Text)
                            {
                                    Line 2 "Properties"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($EnrollmentServer.PreferredBrokerId -eq 0)
                            {
                                    $EnrollmentServerPreferredConnectionBroker = "Automatic"
                            }
                            Else
                            {
                                    $EnrollmentServerPreferredConnectionBroker = (Get-RASBroker -Id $EnrollmentServer.PreferredBrokerId -EA 0 4>$Null).Server
                            }
     
                            If($MSWord -or $PDF)
                            {
 
  -+                                 $ScriptInformation.Add(@{Data = "Enable Enrollment Server"; Value = $EnrollmentServer.Enabled.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Server"; Value = $EnrollmentServer.Server; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $EnrollmentServer.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Preferred Connection Broker"; Value = $EnrollmentServerPreferredConnectionBroker; }) > $Null
 
  <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Enable Enrollment Server`t: " $EnrollmentServer.Enabled.ToString()
                                    Line 3 "Server`t`t`t`t: " $EnrollmentServer.Server
                                    Line 3 "Description`t`t`t: " $EnrollmentServer.Description
                                    Line 3 "Preferred Connection Broker`t: " $EnrollmentServerPreferredConnectionBroker
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Enable Enrollment Server",($Script:htmlsb),$EnrollmentServer.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Server",($Script:htmlsb),$EnrollmentServer.Server,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$EnrollmentServer.Description,$htmlwhite))
                                    $rowdata += @(,("Preferred Connection Broker",($Script:htmlsb),$EnrollmentServerPreferredConnectionBroker,$htmlwhite))
     
                                    $msg = "Properties"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
            
            #HALB
            $HALBs = Get-RASHALB -Siteid $Site.Id -EA 0 4> $Null 
     
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "HALB"
            }
            If($Text)
            {
                    Line 1 "HALB"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "HALB"
            }
     
            If(!$?)
            {
                    Write-Warning "
                                $cnt =-1                   `n
                                ForEach($Site in $PubItem.PublishToSite)                   Unable to retrieve HALBs for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve HALBs for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $HALBs)
            {
                    Write-Host "
            No HALBs retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No HALBs retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No HALBs retrieved for Site $($Site.Name)"
                            Line 0 ""
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No HALBs retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput HALB"
                    ForEach($HALB in $HALBs)
                    {
                            $HALBStatusResult = Get-RASHALBStatus -Name $HALB.Name -EA 0 4> $Null 
                            
                            If($? -and $Null -ne $HALBStatusResult)
                            {
                                    $HALBStatus = GetRASStatus $HALBStatusResult.AgentState
                            }
                            Else
                            {
                                    $HALBStatus = "Unable to determine HALB status"
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "HALB $($HALB.Name)"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "IPv4"; Value = $HALB.VirtualIPV4; }) > $Null
                                    $ScriptInformation.Add(@{Data = "IPv6"; Value = $HALB.VirtualIPV6; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Status"; Value = $HALBStatus; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Public Address"; Value = $HALB.PublicAddress; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $HALB.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $HALB.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $HALB.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $HALB.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "ID"; Value = $HALB.Id.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 2 "HALB $($HALB.Name)"
                                    Line 3 "Name`t`t`t: " $HALB.Name
                                    Line 3 "IPv4`t`t`t: " $HALB.VirtualIPV4
                                    Line 3 "IPv6`t`t`t: " $HALB.VirtualIPV6
                                    Line 3 "Status`t`t`t: " $HALBStatus
                                    Line 3 "Description`t`t: " $HALB.Description
                                    Line 3 "Public Address`t`t: " $HALB.PublicAddress
                                    Line 3 "Last modification by`t: " $HALB.AdminLastMod
                                    Line 3 "Modified on`t`t: " $HALB.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t: " $HALB.AdminCreate
                                    Line 3 "Created on`t`t: " $HALB.TimeCreate.ToString()
                                    Line 3 "ID`t`t`t: " $HALB.Id.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 3 0 "HALB $($HALB.Name)"
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$HALB.Name,$htmlwhite)
                                    $rowdata += @(,("IPv4",($Script:htmlsb),$HALB.VirtualIPV4,$htmlwhite))
                                    $rowdata += @(,("IPv6",($Script:htmlsb),$HALB.VirtualIPV6,$htmlwhite))
                                    $rowdata += @(,("Status",($Script:htmlsb),$HALBStatus,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))
                                    $rowdata += @(,("Public Address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $HALB.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $HALB.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $HALB.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $HALB.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("ID",($Script:htmlsb),$HALB.Id.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "General"
                            }
                            If($Text)
                            {
                                    Line 2 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            Switch($HALB.IPVersion)
                            {
                                    "Version4"              {$HALBIPVersion = "Version 4"; Break}
                                    "Version6"              {$HALBIPVersion = "Version 6"; Break}
                                    "BothVersions"  {$HALBIPVersion = "Both version 4 & 6"; Break}
                                    Default                 {$HALBIPVersion = "Unable to determine IP version: $($HALB.IPVersion)"; Break}
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Enable HALB"; Value = $HALB.EnableHALBInstance.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $HALB.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $HALB.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Public address"; Value = $HALB.PublicAddress; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Virtual IP"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Use IP version"; Value = $HALBIPVersion; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     IPv4"; Value = $HALB.VirtualIPV4; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Subnet Mask"; Value = $HALB.SubNetMask; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     IPv6"; Value = $HALB.VirtualIPV6; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Prefix"; Value = $HALB.PrefixIPV6; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     LB Gateway Payload"; Value = $HALB.EnableGWPayload.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "     LB SSL Payload"; Value = $HALB.EnableSSLPayload.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Device Management"; Value = $HALB.EnableDeviceManagement.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Enable HALB`t`t`t: " $HALB.EnableHALBInstance.ToString()
                                    Line 3 "Name`t`t`t`t: " $HALB.Name
                                    Line 3 "Description`t`t`t: " $HALB.Description
                                    Line 3 "Public address`t`t`t: " $HALB.PublicAddress
                                    Line 3 "Virtual IP"
                                    Line 4 "Use IP version`t`t: " $HALBIPVersion
                                    Line 4 "IPv4`t`t`t: " $HALB.VirtualIPV4
                                    Line 4 "Subnet Mask`t`t: " $HALB.SubNetMask
                                    Line 4 "IPv6`t`t`t: " $HALB.VirtualIPV6
                                    Line 4 "Prefix`t`t`t: " $HALB.PrefixIPV6
                                    Line 3 "Settings"
                                    Line 4 "LB Gateway Payload`t: " $HALB.EnableGWPayload.ToString()
                                    Line 4 "LB SSL Payload`t`t: " $HALB.EnableSSLPayload.ToString()
                                    Line 4 "Device Management`t: " $HALB.EnableDeviceManagement.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Enable HALB",($Script:htmlsb),$HALB.EnableHALBInstance.ToString(),$htmlwhite)
                                    $rowdata += @(,("Name",($Script:htmlsb),$HALB.Name,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$HALB.Description,$htmlwhite))
                                    $rowdata += @(,("Public address",($Script:htmlsb),$HALB.PublicAddress,$htmlwhite))
                                    $rowdata += @(,("Virtual IP",($Script:htmlsb), "",$htmlwhite))
                                    $rowdata += @(,("     Use IP version",($Script:htmlsb), $HALBIPVersion,$htmlwhite))
                                    $rowdata += @(,("     IPv4",($Script:htmlsb), $HALB.VirtualIPV4,$htmlwhite))
                                    $rowdata += @(,("     Subnet Mask",($Script:htmlsb), $HALB.SubNetMask,$htmlwhite))
                                    $rowdata += @(,("     IPv6",($Script:htmlsb), $HALB.VirtualIPV6,$htmlwhite))
                                    $rowdata += @(,("     Prefix",($Script:htmlsb), $HALB.PrefixIPV6,$htmlwhite))
                                    $rowdata += @(,("Settings",($Script:htmlsb), "",$htmlwhite))
                                    $rowdata += @(,("     LB Gateway Payload",($Script:htmlsb), $HALB.EnableGWPayload.ToString(),$htmlwhite))
                                    $rowdata += @(,("     LB SSL Payload",($Script:htmlsb), $HALB.EnableSSLPayload.ToString(),$htmlwhite))
                                    $rowdata += @(,("     Device Management",($Script:htmlsb), $HALB.EnableDeviceManagement.ToString(),$htmlwhite))
     
                                    $msg = "General"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "LB gateway payload"
                            }
                            If($Text)
                            {
                                    Line 2 "LB gateway payload"
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 4 0 "LB gateway payload"
                            }
                            
                            $HALBGatewayPort = $HALB.GatewayConfig.Port.ToString()
                            $HALBGateways    = $HALB.GatewayConfig.Gateways
                            
                            #First, get the port
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Port"; Value = $HALBGatewayPort; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Port: " $HALBGatewayPort
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Port",($Script:htmlsb),$HALBGatewayPort,$htmlwhite)
                                    #$rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #second, process the gateways
                            #do output headers
                            If($MSWord -or $PDF)
                            {
                                    [System.Collections.Hashtable[]] $GatewaysWordTable = @();
                            }
                            If($Text)
                            {
                                    Line 3 "Gateways                                                 Status                                  "
                                    Line 3 "================================================================================================="
                                    #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890
                                    #       1234567890123456789012345678901234567890123456789012345
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                            }
                            
                            #process the gateways data
                            ForEach($GatewayItem in $HALBGateways)
                            {
                                    $ip = $GatewayItem.Keys
                                    $Results = [System.Net.Dns]::gethostentry($ip)
                                    $hostname = $Results.HostName
                                    $TempGW = Get-RASGatewayStatus -Server $hostname -EA 0 4> $Null
                                    $HALBGWStatus = GetRASStatus $TempGW.AgentState
                                    
                                    If($MSWord -or $PDF)
 
  <>                                         $GatewaysWordTableRowHash = @{
                                                    Gateway       = "$hostname ($ip)";
                                                    GatewayStatus = $HALBGWStatus;
                                            }
                                            $GatewaysWordTable += $GatewaysWordTableRowHash
                                    }
                                    If($Text)
                                    {
                                            Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            "$hostname ($ip)",$htmlwhite,
                                            $HALBGWStatus,$htmlwhite))
                                    }
                            }
                            
                            #output the Word/PDF and HTML tables
                            If($MSWord -or $PDF)
                            {
                                    If($GatewaysWordTable.Count -gt 0)
                                    {
                                            $Table = AddWordTable -Hashtable $GatewaysWordTable `
                                            -Columns  Gateway,GatewayStatus `
                                            -Headers  "Gateways","Status"`
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
                                        $cnt++    
                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                            }
                            If($Text)
                            {
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $columnHeaders = @(
                                    "Gateways",($Script:htmlsb),
                                    "Status",($Script:htmlsb))
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "LB SSL payload"
                            }
                            If($Text)
                            {
                                    Line 2 "LB SSL payload"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            $HALBSSLGatewayPort = $HALB.SSLConfig.GatewayConfig.Port.ToString()
                            $HALBSSLGateways    = $HALB.SSLConfig.GatewayConfig.Gateways
                            
                            Switch($HALB.SSLConfig.SSLMode)
                            {
                                    "SSLOffloading"         {$HALBSSLMode = "SSL Offloading"; Break}
                                    "SSLPassthrough"        {$HALBSSLMode = "Passthrough"; Break}
                                    Default                         {$HALBSSLMode = "Unable to etermine SSL Mode: $($HALB.SSLConfig.SSLMode)"; Break}
                            }
                            
                            If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                            {
                                    Switch($HALB.SSLConfig.MinSSLVersion)
                                    {
                                            "SSLv2"         {$HALBSSLAcceptedSSLVersions = "SSL v2 - TLS v1.2 (Weak)"; Break}
                                            "SSLv3"         {$HALBSSLAcceptedSSLVersions = "SSL v3 - TLS v1.2"; Break}
                                            "TLSv1"         {$HALBSSLAcceptedSSLVersions = "TLS v1.0 - TLS v1.2"; Break}
                                            "TLSv1_1"       {$HALBSSLAcceptedSSLVersions = "TLS v1.1 - TLS v1.2"; Break}
                                            "TLSv1_2"       {$HALBSSLAcceptedSSLVersions = "TLS v1.2 only (Strong)"; Break}
                                            Default         {$HALBSSLAcceptedSSLVersions = "Unable to determine Minimum SSL version: $($HALB.SSLConfig.MinSSLVersion)"; Break}
                                    }
                                    
                                    If($HALB.SSLConfig.SSLCipherStrength -eq "Custom")
                                    {
                                            $HALBSSLCipherStrength = "Custom"
                                            $HALBSSLCipher         = $HALB.SSLConfig.SSLCustomCipher
                                    }
                                    Else
                                    {
                                            $HALBSSLCipherStrength = $HALB.SSLConfig.SSLCipherStrength
                                            Switch($HALB.SSLConfig.SSLCipherStrength)
                                            {
                                                    "Low"           {$HALBSSLCipher = "All:!aNULL:!eNULL"; Break}
                                                    "Medium"        {$HALBSSLCipher = "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"; Break}
                                                    "High"          {$HALBSSLCipher = "EECDH:!SSLv2:!aNULL:!RC4:!ADH:!eNULL:!LOW:!MEDIUM:!EXP:+HIGH"; Break}
                                                    Default         {$HALBSSLCipher = "Unable to determine SSL cipher strength: $($HALB.SSLConfig.SSLCipherStrength)"; Break}
                                            }
                                    }
                                    $HALBSSLUseServerPreference = $HALB.SSLConfig.SSLCipherPreference.ToString()
                                    If($HALB.SSLConfig.CertID -eq 0)
                                    {
                                            $HALBSSLCertificates = "All matching usage"
                                    }
                                    Else
                                    {
                                            $Results = Get-RASCertificate -Id $HALB.SSLConfig.CertID -EA 0 4> $Null
                                            
                                            If($? -and $Null -ne $Results)
                                            {
                                                    $HALBSSLCertificates = $Results.Name
                                            }
                                            Else
                                            {
                                                    $HALBSSLCertificates = "Unable to find certificate with an ID of $($HALB.SSLConfig.CertID)"
                                            }
                                    }
                            }
                            Else
                            {
                                    $HALBSSLAcceptedSSLVersions = ""
                                    $HALBSSLCipherStrength      = ""
                                    $HALBSSLCipher              = ""
                                    $HALBSSLUseServerPreference = ""
                                    $HALBSSLCertificates        = ""
                            }
                            
                            #First, get the port
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Port"; Value = $HALBSSLGatewayPort; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Mode"; Value = $HALBSSLMode; }) > $Null
                                    If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                    {
                                            $ScriptInformation.Add(@{Data = "Security"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Accepted SSL Versions"; Value = $HALBSSLAcceptedSSLVersions; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Cipher Strength"; Value = $HALBSSLCipherStrength; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Cipher"; Value = $HALBSSLCipher; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Use ciphers according to server preference"; Value = $HALBSSLUseServerPreference; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Certificates"; Value = $HALBSSLCertificates; }) > $Null
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Port: " $HALBSSLGatewayPort
                                    Line 3 "Mode: " $HALBSSLMode
                                    If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                    {
                                            Line 3 "Security"
                                            Line 4 "Accepted SSL Versions`t`t`t`t: " $HALBSSLAcceptedSSLVersions
                                            Line 4 "Cipher Strength`t`t`t`t`t: " $HALBSSLCipherStrength
                                            Line 4 "Cipher`t`t`t`t`t`t: " $HALBSSLCipher
                                            Line 4 "Use ciphers according to server preference`t: " $HALBSSLUseServerPreference
                                            Line 4 "Certificates`t`t`t`t`t: " $HALBSSLCertificates
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Port",($Script:htmlsb),$HALBSSLGatewayPort,$htmlwhite)
                                    $rowdata += @(,("Mode",($Script:htmlsb),$HALBSSLMode,$htmlwhite))
                                    If($HALB.SSLConfig.SSLMode -eq "SSLOffloading")
                                    {
                                            $rowdata += @(,( "Security",($Script:htmlsb), "",$htmlwhite))
                                            $rowdata += @(,( "     Accepted SSL Versions",($Script:htmlsb), $HALBSSLAcceptedSSLVersions,$htmlwhite))
                                            $rowdata += @(,( "     Cipher Strength",($Script:htmlsb), $HALBSSLCipherStrength,$htmlwhite))
                                            $rowdata += @(,( "     Cipher",($Script:htmlsb), $HALBSSLCipher,$htmlwhite))
                                            $rowdata += @(,( "     Use ciphers according to server preference",($Script:htmlsb), $HALBSSLUseServerPreference,$htmlwhite))
                                            $rowdata += @(,( "     Certificates",($Script:htmlsb), $HALBSSLCertificates,$htmlwhite))
                                    }
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            #second, process the gateways
                            #do output headers
                            If($MSWord -or $PDF)
                            {
                                    [System.Collections.Hashtable[]] $GatewaysWordTable = @();
                            }
                            If($Text)
                            {
                                    Line 3 "Gateways                                                 Status                                  "
                                    Line 3 "================================================================================================="
                                    #       abcdefghijklmno.abcdefghijklmno.local (999.999.999.999)SS1234567890123456789012345678901234567890
                                    #       1234567890123456789012345678901234567890123456789012345
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                            }
                            
                            #process the gateways data
                            ForEach($GatewayItem in $HALBSSLGateways)
                            {
                                    $ip = $GatewayItem.Keys
                                    $Results = [System.Net.Dns]::gethostentry($ip)
                                    $hostname = $Results.HostName
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name                                   $TempGW = Get-RASGatewayStatus -Server $hostname -EA 0 4> $Null
                                    $HALBGWStatus = GetRASStatus $TempGW.AgentState
                                    
                                    If($MSWord -or $PDF)
                                    {
                                            $GatewaysWordTableRowHash = @{
                                                    Gateway       = "$hostname ($ip)";
                                                    GatewayStatus = $HALBGWStatus;
                                            }
                                            $GatewaysWordTable += $GatewaysWordTableRowHash
                                    }
                                    If($Text)
                                    {
                                            Line 3 ( "{0,-55}  {1,-40}" -f "$hostname ($ip)", $HALBGWStatus)
                                    }
                                    If($HTML)
                                    {
                                            $rowdata += @(,(
                                            "$hostname ($ip)",$htmlwhite,
                                            $HALBGWStatus,$htmlwhite))
                                    }
                            }
                            
                            #output the Word/PDF and HTML tables
                            If($MSWord -or $PDF)
                            {
                                    If($GatewaysWordTable.Count -gt 0)
                                    {
                                            $Table = AddWordTable -Hashtable $GatewaysWordTable `
                                            -Columns  Gateway,GatewayStatus `
                                            -Headers  "Gateways","Status"`
                                            -Format $wdTableGrid `
                                            -AutoFit $wdAutoFitFixed;
     
                                            SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                            $Table.Columns.Item(1).Width = 200;
                                            $Table.Columns.Item(2).Width = 250;
     
                                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                            FindWordDocumentEnd
                                            $Table = $Null
                                            WriteWordLine 0 0 ""
                                    }
                            }
                            If($Text)
                            {
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $columnHeaders = @(
                                    "Gateways",($Script:htmlsb),
                                    "Status",($Script:htmlsb))
     
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "600"
                                    WriteHTMLLine 0 0 ""
                            }
    <#
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Device Manager"
                            }
                            If($Text)
                            {
                                    Line 2 "Device Manager"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Port"; Value = ""; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Port: "
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Port",($Script:htmlsb),"",$htmlwhite)
                                    $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
     
                                    $msg = "Device Manager"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
    #>
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Devices"
                            }
                            If($Text)
                            {
                                    Line 2 "Devices"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            $HALBDevices = Get-RASHALBDevice -HALBName $HALB.Name -EA 0 4> $Null
                            
                            If((!$?) -or ($? -and $Null -eq $HALBDevices))
                            {
                                    Write-Host "
                                    No HALB Devices retrieved for HALB $($HALB.Name).`
                                    " -ForegroundColor White
                                    If($MSWord -or $PDF)
                                    {
                                            WriteWordLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                    }
                                    If($Text)
                                    {
                                            Line 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                    }
                                    If($HTML)
                                    {
                                            WriteHTMLLine 0 0 "No HALB Devices retrieved for HALB $($HALB.Name)"
                                    }
                            }
                            Else
                            {
                                    If($MSWord -or $PDF)
                                    {
                                            [System.Collections.Hashtable[]] $HALBDevicesWordTable = @();
                                    }
                                    If($Text)
                                    {
                                            Line 3 "Devices          ID"
                                            Line 3 "==================="
                                            #       999.999.999.999SS12
                                    }
                                    If($HTML)
                                    {
                                            $rowdata = @()
                                    }
                                    
                                    #process the gateways data
                                    ForEach($HALBDevice in $HALBDevices)
                                    {
                                            $ip = $HALBDevice.DeviceIP
                                            $ID = $HALBDevice.DeviceId
 
  <>                                         If($MSWord -or $PDF)
                                            {
                                                    $HALBDevicesWordTableRowHash = @{
                                                            DeviceIP = $ip;
                                                            DeviceID = $ID;
                                                    }
                                                    $HALBDevicesWordTable += $HALBDevicesWordTableRowHash
                                            }
                                        If($cnt -eq 0)                                           If($Text)
 
  <>                                                 Line 3 ( "{0,-15}  {1,-2}" -f $ip, $ID)
                                            }
                                            If($HTML)
                                            {
                                                    $rowdata += @(,(
                                                    $ip,$htmlwhite,
                                                    $ID,$htmlwhite))
                                            }
                                    }
                                    
                                    #output the Word/PDF and HTML tables
                                    If($MSWord -or $PDF)
                                    {
                                            If($HALBDevicesWordTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $HALBDevicesWordTable `
                                                    -Columns  DeviceIP,DeviceID `
                                                    -Headers  "Devices","ID" `
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 100;
                                                    $Table.Columns.Item(2).Width = 50;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    If($Text)
                                    {
                                            Line 0 ""
                                    }
                                    If($HTML)
                                    {
                                            $columnHeaders = @(
                                            "Devices",($Script:htmlsb),
                                            "ID",($Script:htmlsb))
     
                                            $msg = ""
                                            $columnWidths = @("100","50")
                                            FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "150"
                                            WriteHTMLLine 0 0 ""
                                    }
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Advanced"
                            }
                            If($Text)
                            {
                                    Line 2 "Advanced"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Enable RDP UPD tunneling"; Value = $HALB.EnableUDPTunneling.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Maximum TCP connections"; Value = $HALB.MaxTCPConnections.ToString(); }) > $Null
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Client inactivity timeout (s)"; Value = $HALB.ClientIdleTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Gateway connection timeout (s)"; Value = $HALB.GWConnectionTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Client connection queue timeout (s)"; Value = $HALB.ClientQueueTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Gateway inactivity timeout (s)"; Value = $HALB.GatewayIdleTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Amount of TCP connections per second"; Value = $HALB.SessionsRate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Gateways health check intervals (s)"; Value = $HALB.GWHealthCheckInterval.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP virtual router ID"; Value = $HALB.VirtualRouterID.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP authentication password"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP broadcast interval (m)"; Value = $HALB.VrrpBroadcastInterval.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP health check script interval (s)"; Value = $HALB.VrrpHealthCheckInterval.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP health check script timeout"; Value = $HALB.VrrpHealthCheckTimeout.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "VRRP advertisement interval (s)"; Value = $HALB.VrrpAdvertInterval.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Enable OS updates"; Value = $HALB.OSUpdate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Keep existing load balancing settings"; Value = $HALB.KeepLBProxyConfig.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Keep existing VRRP/keepalive settings"; Value = $HALB.KeepVRRPConfig.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                                        }                           }
                            If($Text)
                            {
                                    Line 3 "Enable RDP UPD tunneling`t`t: " $HALB.EnableUDPTunneling.ToString()
                                    Line 3 "Maximum TCP connections`t`t`t: " $HALB.MaxTCPConnections.ToString()
                                    Line 3 "Client inactivity timeout (s)`t`t: " $HALB.ClientIdleTimeout.ToString()
                                    Line 3 "Gateway connection timeout (s)`t`t: " $HALB.GWConnectionTimeout.ToString()
                                    Line 3 "Client connection queue timeout (s)`t: " $HALB.ClientQueueTimeout.ToString()
                                    Line 3 "Gateway inactivity timeout (s)`t`t: " $HALB.GatewayIdleTimeout.ToString()
                                    Line 3 "Amount of TCP connections per second`t: " $HALB.SessionsRate.ToString()
                                    Line 3 "Gateways health check intervals (s)`t: " $HALB.GWHealthCheckInterval.ToString()
                                    Line 3 "VRRP virtual router ID`t`t`t: " $HALB.VirtualRouterID.ToString()
                                    Line 3 "VRRP authentication password`t`t: " 
                                    Line 3 "VRRP broadcast interval (m)`t`t: " $HALB.VrrpBroadcastInterval.ToString()
                                    Line 3 "VRRP health check script interval (s)`t: " $HALB.VrrpHealthCheckInterval.ToString()
                                    Line 3 "VRRP health check script timeout`t: " $HALB.VrrpHealthCheckTimeout.ToString()
                                    Line 3 "VRRP advertisement interval (s)`t`t: " $HALB.VrrpAdvertInterval.ToString()
                                    Line 3 "Enable OS updates`t`t`t: " $HALB.OSUpdate.ToString()
                                    Line 3 "Keep existing load balancing settings`t: " $HALB.KeepLBProxyConfig.ToString()
                                    Line 3 "Keep existing VRRP/keepalive settings`t: " $HALB.KeepVRRPConfig.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Enable RDP UPD tunneling",($Script:htmlsb),$HALB.EnableUDPTunneling.ToString(),$htmlwhite)
                                    $rowdata += @(,("Maximum TCP connections",($Script:htmlsb),$HALB.MaxTCPConnections.ToString(),$htmlwhite))
                                    $rowdata += @(,("Client inactivity timeout (s)",($Script:htmlsb),$HALB.ClientIdleTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("Gateway connection timeout (s)",($Script:htmlsb),$HALB.GWConnectionTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("Client connection queue timeout (s)",($Script:htmlsb),$HALB.ClientQueueTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("Gateway inactivity timeout (s)",($Script:htmlsb),$HALB.GatewayIdleTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("Amount of TCP connections per second",($Script:htmlsb),$HALB.SessionsRate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Gateways health check intervals (s)",($Script:htmlsb),$HALB.GWHealthCheckInterval.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP virtual router ID",($Script:htmlsb),$HALB.VirtualRouterID.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP authentication password",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("VRRP broadcast interval (m)",($Script:htmlsb),$HALB.VrrpBroadcastInterval.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP health check script interval (s)",($Script:htmlsb),$HALB.VrrpHealthCheckInterval.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP health check script timeout",($Script:htmlsb),$HALB.VrrpHealthCheckTimeout.ToString(),$htmlwhite))
                                    $rowdata += @(,("VRRP advertisement interval (s)",($Script:htmlsb),$HALB.VrrpAdvertInterval.ToString(),$htmlwhite))
                                    $rowdata += @(,("Enable OS updates",($Script:htmlsb),$HALB.OSUpdate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Keep existing load balancing settings",($Script:htmlsb),$HALB.KeepLBProxyConfig.ToString(),$htmlwhite))
                                    $rowdata += @(,("Keep existing VRRP/keepalive settings",($Script:htmlsb),$HALB.KeepVRRPConfig.ToString(),$htmlwhite))
     
                                    $msg = "Advanced"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
            
            #Themes
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Themes"
            }
            If($Text)
            {
                    Line 1 "Themes"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Themes"
            }
     
            $Themes = Get-RASTheme -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Themes for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Themes for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Themes for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Themes for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $Themes)
            {
                    Write-Host "
                    No Themes retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Themes retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Themes retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Themes retrieved for Site $($Site.Name)"
                    }
            }
                                        Else           Else
                                        {           {
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Themes"
                    ForEach($Theme in $Themes)
                    {
                            $ThemePostLogonMessage        = $Theme.PostLogonMessage.Split("`n")
                            $ThemeUserPortalPrelogonMessage    = $Theme.UserPortal.Message.PreLogonMessage.Split("`n")
                            $ThemeUserPortalPostlogonMessage   = $Theme.UserPortal.Message.UserPortalPostLogonMessage.Split("`n")
                            $ThemeWindowsPostlogonMessage = $Theme.WindowsClient.Messages.WindowsClientPostLogonMessage.Split("`n")
                            $ThemeUserPortalURL                = "https://FQDN/$($Theme.UserPortal.Url.LoginPageURLPath)"
                            $ThemeShowDownloadURL         = $Theme.UserPortal.Url.ShowDownloadURL.ToString()
                            $ThemeOverrideDownloadURL     = $Theme.UserPortal.Url.OverrideWindowsClientDownloadURL
                            $ThemeFooterURLs              = @(Get-RASThemeFooterURL -Name $Theme.Name -EA 0) 4> $Null #fixed in 2.52 thanks to Thomas Krampe
                            
                            If(!$? -or $Null -eq $ThemeFooterURLs)
                            {
                                    $ThemeFooterURLs = @()
                            }
                            
                            #the Get-RASThemeImage cmdlet returns all four items as an array, but there is nothing that
                            #specifies which array element is which branding image file
                            #I get each image file separately to make sure each image file is correctly associated
                            $ThemeCompanyLogo = Get-RASThemeImage -Name $Theme.name -ImageType CompanyLogo -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    $ThemeCompanyLogo = ""
                            }
                            
                            
                            $ThemeFaviconIcon = Get-RASThemeImage -Name $Theme.name -ImageType FaviconIcon -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    $ThemeFaviconIcon = ""
                            }
     
                            
                            $ThemeConnectionBanner = Get-RASThemeImage -Name $Theme.name -ImageType ConnectionBanner -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    $ThemeConnectionBanner = ""
                            }
     
                            
                            $ThemeApplicationIcon = Get-RASThemeImage -Name $Theme.name -ImageType ApplicationIcon -EA 0 4>$Null
                            
                            If(!$?)
                            {
                                    $ThemeApplicationIcon = ""
                            }
                            
                            $ThemeUserPortalLaunchSessionsUsing = ""
                            Switch($Theme.UserPortal.Gateway.LaunchMethod)
                            {
                                    "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"  
                                    {
                                            $ThemeUserPortalLaunchSessionsUsing = "Launch apps with Parallels Client & Fallback to HTML5"; Break
                                    }
                                    "Launch_Applications_with_Parallels_Client"                                             
                                    {
                                            $ThemeUserPortalLaunchSessionsUsing = "Launch apps with Parallels Client"; Break
                                    }
                                    "Launch_Applications_with_Browser_HTML5"                                                
                                    {
                                            $ThemeUserPortalLaunchSessionsUsing = "Launch apps in Browser only (HTML5 Only)"; Break
                                    }
                                    Default                                                                                                                 
                                    {
                                            $ThemeUserPortalLaunchSessionsUsing = "Unable to determine Launch sessions using: $($Theme.UserPortal.Gateway.LaunchMethod)"; Break
                                    }
                            }
                            
                            $ThemeHTMLFileTransfer = ""
                            Switch($Theme.UserPortal.Gateway.FileTransferMode)
                            {
                                    "Disabled"                      {$ThemeHTMLFileTransfer = "Disabled"; Break}
                                    "ClientToServer"        {$ThemeHTMLFileTransfer = "Client to server only"; Break}
                                    "ServerToClient"        {$ThemeHTMLFileTransfer = "Server to client only"; Break}
                                    "Bidirectional"         {$ThemeHTMLFileTransfer = "Bidirectional"; Break}
                                    Default                         {$ThemeHTMLFileTransfer = "Unable to determine File transfer mode: $($Theme.UserPortal.Gateway.FileTransferMode)"; Break}
                            }
                            
                            $ThemeHTMLClipboardDirection = ""
                            Switch($Theme.UserPortal.Gateway.ClipboardDirection)
                            {
                                    "None"                          {$ThemeHTMLClipboardDirection = "None"; Break}
                                    "ClientToServer"        {$ThemeHTMLClipboardDirection = "Client to server only"; Break}
                                    "ServerToClient"        {$ThemeHTMLClipboardDirection = "Server to client only"; Break}
                                    "Bidirectional"         {$ThemeHTMLClipboardDirection = "Bidirectional"; Break}
                                    Default                         {$ThemeHTMLClipboardDirection = "Unable to determine Clipboard direction: $($Theme.UserPortal.Gateway.ClipboardDirection)"; Break}
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Theme $($Theme.Name)"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null                                   $ScriptInformation.Add(@{Data = "Name"; Value = $Theme.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $Theme.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "HTML5 URL"; Value = $ThemeUserPortalURL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Theme.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $Theme.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $Theme.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $Theme.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "ID"; Value = $Theme.Id.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 2 "Theme $($Theme.Name)"
                                    Line 3 "Name`t`t`t: " $Theme.Name
                                    Line 3 "Description`t`t: " $Theme.Description
                                    Line 3 "HTML5 URL`t`t: " $ThemeUserPortalURL
                                    Line 3 "Last modification by`t: " $Theme.AdminLastMod
                                    Line 3 "Modified on`t`t: " $Theme.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t: " $Theme.AdminCreate
                                    Line 3 "Created on`t`t: " $Theme.TimeCreate.ToString()
                                    Line 3 "ID`t`t`t: " $Theme.Id.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $ThemeName = $Theme.Name.Replace("<","").Replace(">","")
                                    WriteHTMLLine 3 0 "Theme $ThemeName"
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$ThemeName,$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))
                                    $rowdata += @(,("HTML5 URL",($Script:htmlsb),$ThemeUserPortalURL,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $Theme.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $Theme.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $Theme.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $Theme.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("ID",($Script:htmlsb),$Theme.Id.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "General"
                            }
                            If($Text)
                            {
                                    Line 2 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Enable Theme"; Value = $Theme.Enabled.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $Theme.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $Theme.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Override authentication domain"; Value = $Theme.OverrideAuthenticationDomain.ToString(); }) > $Null
                                    If($Theme.OverrideAuthenticationDomain)
                                    {
                                            $ScriptInformation.Add(@{Data = "     Domain"; Value = $Theme.Domain; }) > $Null
                                    }
                                    $ScriptInformation.Add(@{Data = "Limit access to this theme to members of these AD groups"; Value = $Theme.GroupEnabled.ToString(); }) > $Null
                                    If($Theme.GroupEnabled)
                                    {
                                            ForEach($Group in $Theme.GroupFilters)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Group: $($Group.name) SID: $($Group.sid)"; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                         }
                            If($Text)
                            {
                                    Line 3 "Enable Theme`t`t`t: " $Theme.Enabled.ToString()
                                    Line 3 "Name`t`t`t`t: " $Theme.Name
                                WriteWordLine 3 0 "Remote PC Application"                                   Line 3 "Description`t`t`t: " $Theme.Description
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $ThemeName = $Theme.Name.Replace("<","").Replace(">","")
                                    $rowdata = @()
                                    $columnHeaders = @("Enable Theme",($Script:htmlsb),$Theme.Enabled.ToString(),$htmlwhite)
                                    $rowdata += @(,("Name",($Script:htmlsb),$ThemeName,$htmlwhite))
                                    $rowdata += @(,("Description",($Script:htmlsb),$Theme.Description,$htmlwhite))
     
                                    $msg = "General"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                WriteWordLine 4 0 "Application"                                   WriteWordLine 4 0 "Access"
                            }
                            If($Text)
                            {
                                    Line 2 "Access"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            $Results = Get-RASMFA -Id $Theme.MFAId -EA 0 4>$Null
                            
                            If($? -and $Null -ne $Results)
                            {
                                    $MFAProvider = $Results.Name
                            }
                            Else
                            {
                                    $MFAProvider = "Unable to determine MFA provider"
                            }
                            
                            $Results = Get-RASSAMLIDP -SiteId $Site.Id -EA 0 4>$Null | Where-Object {$_.ThemeId -eq $Theme.Id}
                            
                            If($? -and $Null -ne $Results)
                            {
                                    $SAMLProvider = $Results.Name
                            }
                            Else
                            {
                                    $SAMLProvider = ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
 
                                $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Override authentication domain"; Value = $Theme.OverrideAuthenticationDomain.ToString(); }) > $Null
                                    If($Theme.OverrideAuthenticationDomain)
                                    {
                                $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Domain"; Value = $Theme.Domain; }) > $Null
                                    }
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null                                   $ScriptInformation.Add(@{Data = "Limit access to this theme to members of these AD groups"; Value = $Theme.GroupEnabled.ToString(); }) > $Null
                                    If($Theme.GroupEnabled)
                                    {
                                            ForEach($Group in $Theme.GroupFilters)
                                            {
                                $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Group: $($Group.name) SID: $($Group.sid)"; }) > $Null
                                            }
                                    }
                                $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null                                   $ScriptInformation.Add(@{Data = "MFA provider"; Value = $MFAProvider; }) > $Null
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "SAML Single Sign-in IdP"; Value = $SAMLProvider; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
                                 +-  
                                OutputPubItemFilters $PubItem "MSWordPDF"    
                                    
                                OutputPubItemShortcuts $PubItem "MSWordPDF" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                                Line 2 "Information" <>  
                                Line 3 "Remote PC Application`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"    
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description    
                                Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod    
                                Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()    
                                Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate    
                                Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()    
                                Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target    
                                Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn    
                                Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()                                   Line 3 "Override authentication domain`t: " $Theme.OverrideAuthenticationDomain.ToString()
                                    
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters    
                                }    
                                    
                                Line 3 "Settings for Site $xSiteName"    
     
                                If($PubItem.InheritShortcutDefaultSettings)                                   If($Theme.OverrideAuthenticationDomain)
 
                                        If($DefaultCreateShortcutOnDesktop -eq "True") <>                                         Line 6 "Domain  : " $Theme.Domain
                                        {    
                                                Line 3 "Create shortcut on desktop"    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"    
                                        }    
 
                                Else <>  
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                Line 3 "Create shortcut on desktop"                                   Line 3 "Limit access to this theme to "
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"                                   Line 3 "members of these AD groups`t: " $Theme.GroupEnabled.ToString()
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 "Own Filters"    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        Line 3 " User filtering is enabled"    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                Line 10 "  " $Item.Account    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        Line 3 " IP filtering is enabled"    
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        Line 3 " Client filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        Line 3 " MAC filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.GWFilterEnabled)                                   If($Theme.GroupEnabled)
 
                                        Line 3 " Gateway filtering is enabled" <>  
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 " Client device operating system filtering is enabled"    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                Line 10 "  Android"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                Line 10 "  ChromeApp"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                Line 10 "  iOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                Line 10 "  Linux"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                Line 10 "  macOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                Line 10 "  RAS Web Portal"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                Line 10 "  Windows"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                Line 10 "  Wyse"    
                                        }    
                                        Line 0 ""    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)                                           ForEach($Group in $Theme.GroupFilters)
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
 
                                                Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName <>                                                 Line 7 "  Group: $($Group.name) SID: $($Group.sid)"
 
                                        Else +-  
                                        {    
                                                Line 10 $SiteName    
                                        }    
 
                                Line 0 "" <>                                 Line 3 "MFA provider`t`t`t: " $MFAProvider
                                    Line 3 "SAML Single Sign-in IdP`t`t: " $SAMLProvider
                                Line 2 "Sites"    
                                Line 3 "This published item will be available from the following Sites"    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        Line 10 $SiteName    
                                }    
 
  +-  
                                Line 2 "Remote PC Application"    
                                Line 3 "Application"    
                                Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name    
                                Line 4 "Description`t`t`t`t`t: " $PubItem.Description    
                                Line 4 "Run`t`t`t`t`t`t: " $WinType    
                                Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target    
                                Line 4 "Start In`t`t`t`t`t: " $PubItem.StartIn    
                                Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters    
                                Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()    
                                Line 0 ""    
                                    
                                OutputPubItemFilters $PubItem "Text"    
                                    
                                OutputPubItemShortcuts $PubItem "Text" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                                WriteHTMLLine 3 0 "Information" <>                                 $ThemeName = $Theme.Name.Replace("<","").Replace(">","")
 
  <>  
                                $columnHeaders = @("Remote PC Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))    
                                $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))    
                                $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))    
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))                                   $columnHeaders = @("Override authentication domain",($Script:htmlsb),$Theme.OverrideAuthenticationDomain.ToString(),$htmlwhite)
                                    
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
                                }    
                                    
                                $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))    
                                    
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)                                   If($Theme.OverrideAuthenticationDomain)
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
 
                                        $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite)) <>  
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))                                           $rowdata += @(,("     Domain",($Script:htmlsb),$Theme.Domain,$htmlwhite))
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
 
                                If($PubItem.ClientFilterEnabled) <>  
                                {    
                                        $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Limit access to this theme to members of these AD groups",($Script:htmlsb),$Theme.GroupEnabled.ToString(),$htmlwhite))
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)                                   If($Theme.GroupEnabled)
 
                                        $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite)) <>  
                                            
                                        ForEach($item in $PubItem.AllowedGWs)                                           ForEach($Group in $Theme.GroupFilters)
 
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Group: $($Group.name) SID: $($Group.sid)",$htmlwhite))
 
                                If($PubItem.OSFilterEnabled) <>  
                                {    
                                        $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))                                   $rowdata += @(,("MFA provider",($Script:htmlsb),$MFAProvider,$htmlwhite))
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))                                   $rowdata += @(,("SAML Single Sign-in IdP",($Script:htmlsb),$SAMLProvider,$htmlwhite))
                                        }    
                                                                          
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
                            
                                $msg = ""                                   $msg = "Access"
                                $columnWidths = @("200","300")                                   $columnWidths = @("200","400")
 
  <>  
                                WriteHTMLLine 3 0 "Sites"    
                                $rowdata = @()    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)    
                                        }                           }
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Remote PC Application"    
                                $rowdata = @()    
     
                                $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Run",($Script:htmlsb),$WinType,$htmlwhite))    
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
     
                                $msg = "Application"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                                                          
                                OutputPubItemFilters $PubItem "HTML"                           If($MSWord -or $PDF)
                                    
                                OutputPubItemShortcuts $PubItem "HTML" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
                        }    
                }    
                ElseIf($PubItem.Type -eq "PCDesktop")    
                {    
                        $DesktopSize = "Unable to determine"    
                        If($PubItem.DesktopSize -eq "FullScreen")    
 
                                $DesktopSize = "Full Screen" <>                                 WriteWordLine 4 0 "Messages"
 
                        ElseIf($PubItem.DesktopSize -eq "UseAvailableArea") <>                         If($Text)
 
                                $DesktopSize = "Use available area" <>                                 Line 2 "Messages"
 
                        Else <>                         If($HTML)
 
                                $DesktopSize = "$($PubItem.Width.ToString())x$($PubItem.Height.ToString())" <>  
                        }                                   #Nothing
                            
                        If($PubItem.AllowMultiMonitor -eq "UseClientSettings")    
                        {    
                                $AllowMultiMonitor = "Use Client Settings"    
 
                        Else +-  
                        {    
                                $AllowMultiMonitor = $PubItem.AllowMultiMonitor.ToString()    
                        }    
 
                                WriteWordLine 3 0 "Information" +-  
                                    
 
                                $ScriptInformation.Add(@{Data = "Remote PC Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null    
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null    
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
                                }    
     
                                $cnt =-1                                   $cnt = -1
                                ForEach($Site in $PubItem.PublishToSite)                                   ForEach($line in $ThemePostLogonMessage)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
 
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "Post-logon message:"; Value = $line; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                         }
                            If($Text)
                            {
                                    $cnt = -1
                                    ForEach($line in $ThemePostLogonMessage)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Post-logon message: " $line
                                            }
                                            Else
                                            {
                                                    Line 5 "    " $line
                                            }
                                    }
                                WriteWordLine 3 0 "Sites"                                   Line 0 ""
                                $ScriptInformation = New-Object System.Collections.ArrayList                           }
                            If($HTML)
                            {
                                    $rowdata = @()
                                $cnt =-1                                   $cnt = -1
                                ForEach($Site in $PubItem.PublishToSite)                                   ForEach($line in $ThemePostLogonMessage)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
 
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null <>                                                 $columnHeaders = @("Post-logon message:",($Script:htmlsb),$line,$htmlwhite)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))
 
  -+  
                                    $msg = "Messages"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/URLs"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/URLs"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Theme login page:"; Value = $ThemeUserPortalURL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Show Parallels Client download URL"; Value = $ThemeShowDownloadURL; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Override download URL for branded Parallels Client (Windows)"; Value = $ThemeOverrideDownloadURL; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                                 
                                    If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty
                                    {
                                WriteWordLine 3 0 "Remote PC Desktop"                                           WriteWordLine 4 0 "Footer URLs:"
                                            [System.Collections.Hashtable[]] $URLWordTable = @();
                                            
                                            ForEach($FooterURL in $ThemeFooterURLs)
                                            {
                                                    $URLTableRowHash = @{
                                                    URL     = $FooterURL.URL;
                                                    Text    = $FooterURL.Text;
                                                    Tooltip = $FooterURL.Tooltip;
                                                    }
                                                    $URLWordTable += $URLTableRowHash;
                                            }
     
                                            If($URLWordTable.Count -gt 0)
                                            {
                                                    $Table = AddWordTable -Hashtable $URLWordTable `
                                                    -Columns  URL,Text,Tooltip `
                                                    -Headers  "URL","Text","Tooltip"`
                                                    -Format $wdTableGrid `
                                                    -AutoFit $wdAutoFitFixed;
     
                                                    SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                                    $Table.Columns.Item(1).Width = 150;
                                                    $Table.Columns.Item(2).Width = 150;
                                                    $Table.Columns.Item(3).Width = 150;
     
                                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                                    FindWordDocumentEnd
                                                    $Table = $Null
                                                    WriteWordLine 0 0 ""
                                            }
                                    }
                                    Else
                                    {
                                WriteWordLine 4 0 "Remote PC Desktop"                                           WriteWordLine 4 0 "Footer URLs:"
                                            WriteWordLine 0 0 "There are no Footer URLs"
                                            WriteWordLine 0 0 ""
                                    }       
                            }
                            If($Text)
                            {
                                    Line 3 "Theme login page`t`t  : " $ThemeUserPortalURL
                                    Line 3 "Show Parallels Client download URL: " $ThemeShowDownloadURL
                                    Line 3 "Override download URL for branded "
                                    Line 3 "Parallels Client (Windows)`t  : " $ThemeOverrideDownloadURL
                                    Line 0 ""
     
                                    If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty
                                    {
                                            Line 3 "Footer URLs:"
                                            Line 3 "URL                             Text                            Tooltip                       "
                                            Line 3 "=============================================================================================="
                                            #       123456789012345678901234567890SS123456789012345678901234567890SS123456789012345678901234567890
     
                                            ForEach($FooterURL in $ThemeFooterURLs)
                                            {
                                                    Line 3 ( "{0,-30}  {1,-30}  {2,-30}" -f `
                                                    $FooterURL.URL, $FooterURL.Text, $FooterURL.Tooltip)
                                            }
                                            
                                            Line 0 ""
                                    }
                                    Else
                                    {
                                            Line 3 "Footer URLs:"
                                            Line 3 "There are no Footer URLs"
                                            Line 0 ""
                                    }       
                            }
                            If($HTML)
                            {
                                    $ThemeName = $Theme.Name.Replace("<","").Replace(">","")
                                    $rowdata = @()
                                    $columnHeaders = @("Theme login page:",($Script:htmlsb),$ThemeUserPortalURL,$htmlwhite)
                                    $rowdata += @(,("Show Parallels Client download URL",($Script:htmlsb),$ThemeShowDownloadURL,$htmlwhite))
                                    $rowdata += @(,("Override download URL for branded Parallels Client (Windows)",($Script:htmlsb),$ThemeOverrideDownloadURL,$htmlwhite))
     
                                    $msg = "User Portal (Web client)/URLs"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    If($ThemeFooterURLs -is [array] -and $ThemeFooterURLs.Count -gt 0) #don't process if array is empty
                                    {
                                            $rowdata = @()
     
                                            ForEach($FooterURL in $ThemeFooterURLs)
                                            {
                                                    $rowdata += @(,(
                                                    $FooterURL.URL,$htmlwhite,
                                                    $FooterURL.Text,$htmlwhite,
                                                    $FooterURL.Tooltip,$htmlwhite))
                                            }
     
                                            $columnHeaders = @(
                                            "URL",($Script:htmlsb),
                                            "Text",($Script:htmlsb),
                                            "Tooltip",($Script:htmlsb))
     
                                            $msg = "Footer URLs:"
                                            $columnWidths = @("150","150","150")
                                            FormatHTMLTable $msg -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths -tablewidth "450"
                                            WriteHTMLLine 0 0 ""
                                    }
                                    Else
                                    {
                                            WriteHTMLLine 4 0 "Footer URLs:"
                                            WriteHTMLLine 0 0 "There are no Footer URLs"
                                            WriteHTMLLine 0 0 ""
                                    }       
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Branding"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Branding"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
 
                                $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Webpage title"; Value = $Theme.UserPortal.Branding.WebpageTitle; }) > $Null
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null                                   $ScriptInformation.Add(@{Data = "Login to"; Value = $Theme.UserPortal.Branding.LoginTo; }) > $Null
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Company logo"; Value = $ThemeCompanyLogo; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Favicon icon"; Value = $ThemeFaviconIcon; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 3 "Webpage title`t: " $Theme.UserPortal.Branding.WebpageTitle
                                    Line 3 "Login to`t: " $Theme.UserPortal.Branding.LoginTo
                                    Line 3 "Company logo`t: " $ThemeCompanyLogo
                                    Line 3 "Favicon icon`t: " $ThemeFaviconIcon
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Webpage title",($Script:htmlsb),$Theme.UserPortal.Branding.WebpageTitle,$htmlwhite)
                                    $rowdata += @(,("Login to",($Script:htmlsb),$Theme.UserPortal.Branding.LoginTo,$htmlwhite))
                                    $rowdata += @(,("Company logo",($Script:htmlsb),$ThemeCompanyLogo,$htmlwhite))
                                    $rowdata += @(,("Favicon icon",($Script:htmlsb),$ThemeFaviconIcon,$htmlwhite))
 
  <>                                 $msg = "User Portal (Web client)/Branding"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
     
                            If($MSWord -or $PDF)
                            {
                                WriteWordLine 4 0 "Properties"                                   WriteWordLine 4 0 "User Portal (Web client)/Colors"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Colors"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
     
                            $HeaderBackgroundColor      = '{0:X}' -f $Theme.UserPortal.Color.HeaderBackgroundColor     
                            $SubHeaderBackgroundColor   = '{0:X}' -f $Theme.UserPortal.Color.SubHeaderBackgroundColor  
                            $SubHeaderTextColor         = '{0:X}' -f $Theme.UserPortal.Color.SubHeaderTextColor        
                            $WorkAreaBackgroundColor    = '{0:X}' -f $Theme.UserPortal.Color.WorkAreaBackgroundColor   
                            $WorkAreaTextColor          = '{0:X}' -f $Theme.UserPortal.Color.WorkAreaTextColor         
                            $ButtonsBackgroundColor     = '{0:X}' -f $Theme.UserPortal.Color.ButtonsBackgroundColor    
                            $ButtonsTextColor           = '{0:X}' -f $Theme.UserPortal.Color.ButtonsTextColor          
                            $SelectionHighlightingColor = '{0:X}' -f $Theme.UserPortal.Color.SelectionHighlightingColor
                            $AlertBackgroundColor       = '{0:X}' -f $Theme.UserPortal.Color.AlertBackgroundColor      
                            $AlertTextColor             = '{0:X}' -f $Theme.UserPortal.Color.AlertTextColor            
     
                            If($MSWord -or $PDF)
                            {
 
  <>                                 $ScriptInformation.Add(@{Data = "Header background" ; Value = $HeaderBackgroundColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Sub-header background" ; Value = $SubHeaderBackgroundColor; }) > $Null
                                #$ScriptInformation.Add(@{Data = "Select Remote PC"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Sub-header text" ; Value = $SubHeaderTextColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Work area background" ; Value = $WorkAreaBackgroundColor; }) > $Null
                                $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null                                   $ScriptInformation.Add(@{Data = "Work area text" ; Value = $WorkAreaTextColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Buttons background and links" ; Value = $ButtonsBackgroundColor; }) > $Null
                                $ScriptInformation.Add(@{Data = "Multi-Monitor"; Value = $AllowMultiMonitor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Button text" ; Value = $ButtonsTextColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Selection highlighting" ; Value = $SelectionHighlightingColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Alert background" ; Value = $AlertBackgroundColor; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Alert text" ; Value = $AlertTextColor; }) > $Null
                                    
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  +-  
                                OutputPubItemFilters $PubItem "MSWordPDF"    
     
                                OutputPubItemShortcuts $PubItem "MSWordPDF" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                                Line 2 "Information" <>  
                                Line 3 "Remote PC Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"    
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description    
                                Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod    
                                Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()    
                                Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate    
                                Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()    
                                Line 3 "Desktop Size`t`t`t`t`t`t: " $DesktopSize    
     
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                Line 3 "Create shortcut on desktop"                                   Line 3 "Header background`t`t: " $HeaderBackgroundColor
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"                                   Line 3 "Sub-header background`t`t: " $SubHeaderBackgroundColor
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")                                   Line 3 "Sub-header text`t`t`t: " $SubHeaderTextColor
                                        {                                   Line 3 "Work area background`t`t: " $WorkAreaBackgroundColor
                                                Line 3 "Create shortcut in Auto Start Folder"                                   Line 3 "Work area text`t`t`t: " $WorkAreaTextColor
                                        }                                   Line 3 "Buttons background and links`t: " $ButtonsBackgroundColor
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                Line 3 "Create shortcut on desktop"                                   Line 3 "Button text`t`t`t: " $ButtonsTextColor
                                        }                                   Line 3 "Selection highlighting`t`t: " $SelectionHighlightingColor
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                Line 3 "Create shortcut in Auto Start Folder"                                   Line 3 "Alert background`t`t: " $AlertBackgroundColor
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 "Own Filters"    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        Line 3 " User filtering is enabled"    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                Line 10 "  " $Item.Account    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        Line 3 " IP filtering is enabled"    
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                Line 10 "  " $item.From    
                                                        }    
                                                        Else    
                                                        {    
                                                                Line 10 "  $($item.From) - $($item.To)"    
                                                        }    
                                                }    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        Line 3 " Client filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        Line 3 " MAC filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        Line 3 " Gateway filtering is enabled"    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                Line 10 "  " $Item    
                                        }    
                                        Line 0 ""    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        Line 3 " Client device operating system filtering is enabled"    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                Line 10 "  Android"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                Line 10 "  ChromeApp"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                Line 10 "  iOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                Line 10 "  Linux"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                Line 10 "  macOS"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                Line 10 "  RAS Web Portal"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                Line 10 "  Windows"    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                Line 10 "  Wyse"    
                                        }    
                                        Line 0 ""    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                Line 3 "Available in Site(s):`t`t`t`t`t" $SiteName                                   Line 3 "Alert text`t`t`t: " $AlertTextColor
                                        }    
                                        Else    
                                        {    
                                                Line 10 $SiteName    
                                        }    
                                }    
 
  +-  
                                Line 2 "Sites"    
                                Line 3 "This published item will be available from the following Sites"    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        Line 10 $SiteName    
                                }    
                                Line 0 ""    
     
                                Line 2 "Remote PC Desktop"    
                                Line 3 "Remote PC Desktop"    
                                Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name    
                                Line 4 "Description`t`t`t`t`t: " $PubItem.Description    
                                Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()    
                                Line 0 ""    
                                Line 3 "Properties"    
                                Line 4 "Desktop Size`t`t`t`t`t: " $DesktopSize    
                                Line 4 "Multi-Monitor`t`t`t`t`t: " $AllowMultiMonitor    
                                Line 0 ""    
     
                                OutputPubItemFilters $PubItem "Text"    
                                    
                                OutputPubItemShortcuts $PubItem "Text" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                                WriteHTMLLine 3 0 "Information" +-  
 
  <>  
                                $columnHeaders = @("Remote PC Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)                                   $columnHeaders = @("Header background" ,($Script:htmlsb),$HeaderBackgroundColor,$htmlwhite)
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))    
                                $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))                                   $rowdata += @(,("Sub-header background" ,($Script:htmlsb),$SubHeaderBackgroundColor,$htmlwhite))
                                $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))                                   $rowdata += @(,("Sub-header text" ,($Script:htmlsb),$SubHeaderTextColor,$htmlwhite))
                                $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))                                   $rowdata += @(,("Work area background" ,($Script:htmlsb),$WorkAreaBackgroundColor,$htmlwhite))
                                $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))                                   $rowdata += @(,("Work area text" ,($Script:htmlsb),$WorkAreaTextColor,$htmlwhite))
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Buttons background and links",($Script:htmlsb),$ButtonsBackgroundColor,$htmlwhite))
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Button text" ,($Script:htmlsb),$ButtonsTextColor,$htmlwhite))
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Selection highlighting" ,($Script:htmlsb),$SelectionHighlightingColor,$htmlwhite))
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Alert background" ,($Script:htmlsb),$AlertBackgroundColor,$htmlwhite))
                                        }    
                                }    
     
                                If($PubItem.UserFilterEnabled -or     
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))                                   $rowdata += @(,("Alert text" ,($Script:htmlsb),$AlertTextColor,$htmlwhite))
                                }    
 
                                If($PubItem.UserFilterEnabled) <>  
                                {    
                                        $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)                                   $msg = "User Portal (Web client)/Colors"
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))    
                                                        }    
                                                        Else    
                                                        {    
                                                                $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")                                   $columnWidths = @("200","275")
 
  <>  
                                WriteHTMLLine 3 0 "Sites"    
                                $rowdata = @()    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)    
                                        }                           }
                                        Else    
                            If($MSWord -or $PDF)
                                        {                           {
                                                $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))    
                                        }    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Remote PC Desktop"    
                                $rowdata = @()    
                                $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)    
                                $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 4 0 "Properties"                                   WriteWordLine 4 0 "User Portal (Web client)/Language bar"
                                $rowdata = @()    
                                $columnHeaders = @("Select Remote PC",($Script:htmlsb),"",$htmlwhite)    
                                $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))    
                                $rowdata += @(,("Multi-Monitor",($Script:htmlsb),$AllowMultiMonitor,$htmlwhite))    
                                    
                                $msg = "Remote PC Desktop"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                OutputPubItemFilters $PubItem "HTML"    
     
                                OutputPubItemShortcuts $PubItem "HTML" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
 
                } <>                         If($Text)
                ElseIf($PubItem.Type -eq "RDSApp")    
                {    
                        Switch ($PubItem.ConCurrentLicenses)    
 
                                0               {$ConCurrentLicenses = "Unlimited"; Break} <>                                 Line 2 "User Portal (Web client)/Language bar"
                                Default {$ConCurrentLicenses = $PubItem.ConCurrentLicenses.ToString(); Break}     
 
                        <>                         If($HTML)
                        Switch ($PubItem.DisableSessionSharing)    
 
                                $False  {$SessionSharing = "Enabled"; Break} <>  
                                $True   {$SessionSharing = "Disabled"; Break}    
                                Default {$SessionSharing = "Unable to determine Session Sharing state: $($PubItem.DisableSessionSharing)"; Break}    
                        }                                   #Nothing
                            
                        Switch ($PubItem.PublishFrom)    
                        {    
                                "All"           {$PublishedFrom = "All Servers in Site"; Break}    
                                "Group"         {$PublishedFrom = "Server Groups:"; Break}    
                                "Server"        {$PublishedFrom = "Individual Servers:"; Break}    
                                Default         {$PublishedFrom = "Unable to determine Published From: $($PubItem.PublishFrom)"; Break}    
 
                        Switch ($PubItem.LicenseLimitNotify) +-  
                        {    
                                "WarnUserAndNoStart"            {$LicenseLimitNotify ="Warn user and do not start"; Break}    
                                "WarnUserAndStart"                      {$LicenseLimitNotify ="Warn user and start"; Break}    
                                "NotifyAdminAndStart"           {$LicenseLimitNotify ="Notify administrator and start"; Break}    
                                "NotifyUserAdminAndStart"       {$LicenseLimitNotify ="Notify user, administrator and start"; Break}    
                                "NotifyUserAdminAndNoStart"     {$LicenseLimitNotify ="Notify user, administrator and do not start"; Break}    
                                Default {$LicenseLimitNotify ="Unable to determine If limit is exceeded: $($PubItem.LicenseLimitNotify)"; Break}    
                        }    
                            
                        Switch ($PubItem.ColorDepth)    
                        {    
                                "Colors8Bit"            {$ColorDepth = "256 Colors"; Break}    
                                "Colors15Bit"           {$ColorDepth = "High Color (15 bit)"; Break}    
                                "Colors16Bit"           {$ColorDepth = "High Color (16 bit)"; Break}    
                                "Colors24Bit"           {$ColorDepth = "True Color (24 bit)"; Break}    
                                "Colors32Bit"           {$ColorDepth = "Highest Quality (32 bit)"; Break}    
                                "ClientSpecified"       {$ColorDepth = "Client Specified"; Break}    
                                Default                         {$ColorDepth = "Unable to determine Color Depth: $($PubItem.ColorDepth)"; Break}    
                        }    
                            
                        Switch($PubItem.EnabledMode)    
                        {    
                                "Disabled"              {$PubItemMode = "Disabled"; Break}    
                                "Enabled"               {$PubItemMode = "Enabled"; Break}    
                                "Maintenance"   {$PubItemMode = "In maintenance"; Break}    
                                Default                 {$PubItemMode = "Unable to determine Enabled Mode: $($PubItem.EnabledMode)"; Break}    
                        }    
     
 
                                WriteWordLine 3 0 "Information" +-  
 
                                $ScriptInformation.Add(@{Data = "Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>  
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Default language"   ; Value = $Theme.UserPortal.LanguageBar.Default.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Status"; Value = $PubItemMode; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null                                   $ScriptInformation.Add(@{Data = "English"            ; Value = $Theme.UserPortal.LanguageBar.en_US.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "German"             ; Value = $Theme.UserPortal.LanguageBar.de_DE.ToString(); }) > $Null
     
                                If(![String]::IsNullOrEmpty($PubItem.Parameters))    
                                {    
                                        $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null                                   $ScriptInformation.Add(@{Data = "Japanese"           ; Value = $Theme.UserPortal.LanguageBar.ja_JP.ToString(); }) > $Null
                                }    
                                    
                                If($PubItem.EnableFileExtensions)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Associate the following file extensions"; Value = ""; }) > $Null    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                    
                                If($PubItem.InheritLicenseDefaultSettings)    
                                {    
                                        If($DefaultOneInstancePerUser)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null    
                                        }    
                                        $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $DefaultConCurrentLicenses; }) > $Null                                   $ScriptInformation.Add(@{Data = "Russian"            ; Value = $Theme.UserPortal.LanguageBar.ru_RU.ToString(); }) > $Null
                                        $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $DefaultLicenseLimitNotify; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $DefaultDisableSessionSharing ; }) > $Null                                   $ScriptInformation.Add(@{Data = "French"             ; Value = $Theme.UserPortal.LanguageBar.fr_FR.ToString(); }) > $Null
                                }    
                                Else    
                                {    
                                        If($PubItem.OneInstancePerUser)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null    
                                        }    
                                        $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $ConCurrentLicenses; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $LicenseLimitNotify; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $SessionSharing; }) > $Null                                   $ScriptInformation.Add(@{Data = "Spanish"            ; Value = $Theme.UserPortal.LanguageBar.es_ES.ToString(); }) > $Null
                                }    
     
                                $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Italian"            ; Value = $Theme.UserPortal.LanguageBar.it_IT.ToString(); }) > $Null
                                    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "Published from"; Value = "All Servers in Site"; }) > $Null    
                                }    
     
                                If($PubItem.InheritShortcutDefaultSettings)    
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Portuguese"         ; Value = $Theme.UserPortal.LanguageBar.pt_BR.ToString(); }) > $Null
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Chinese Simplified" ; Value = $Theme.UserPortal.LanguageBar.zh_CN.ToString(); }) > $Null
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Chinese Traditional"; Value = $Theme.UserPortal.LanguageBar.zh_TW.ToString(); }) > $Null
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null                                   $ScriptInformation.Add(@{Data = "Korean"             ; Value = $Theme.UserPortal.LanguageBar.ko_KR.ToString(); }) > $Null
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Dutch"              ; Value = $Theme.UserPortal.LanguageBar.nl_NL.ToString(); }) > $Null
                                        }    
                                }    
 
                                If($PubItem.UserFilterEnabled -or  +-  
                                   $PubItem.ClientFilterEnabled -or     
                                   $PubItem.IPFilterEnabled -or     
                                   $PubItem.MACFilterEnabled -or     
                                   $PubItem.GWFilterEnabled -or     
                                   $PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null    
                                }    
     
                                If($PubItem.UserFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($Item in $PubItem.AllowedUsers)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null    
                                        }    
                                }    
                                If($PubItem.IPFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null    
     
                                        If($PubItem.AllowedIP4s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP4s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
     
                                        If($PubItem.AllowedIP6s.Count -gt 0)    
                                        {    
                                                ForEach($item in $PubItem.AllowedIP6s)    
                                                {    
                                                        If($item.From -eq $item.To)    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null    
                                                        }    
                                                        Else    
                                                        {    
                                                                $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null    
                                                        }    
                                                }    
                                        }    
                                }    
                                If($PubItem.ClientFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedClients)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.MACFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedMACs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.GWFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        ForEach($item in $PubItem.AllowedGWs)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null    
                                        }    
                                }    
                                If($PubItem.OSFilterEnabled)    
                                {    
                                        $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null    
                                            
                                        If($PubItem.AllowedOSes.Android)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Chrome)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.HTML5)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.iOS)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Linux)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Mac)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.WebPortal)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Windows)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null    
                                        }    
                                            
                                        If($PubItem.AllowedOSes.Wyse)    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null    
                                        }    
                                }    
     
                                $cnt =-1    
                                ForEach($Site in $PubItem.PublishToSite)    
                                {    
                                        $cnt++    
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name    
                                            
                                        If($cnt -eq 0)    
                                        {    
                                                $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null    
                                        }    
                                        Else    
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null    
                                        }    
                                }    
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                         }
                            If($Text)
                            {
                                    Line 3 "Default language`t: "    $Theme.UserPortal.LanguageBar.Default.ToString()
                                    Line 3 "English`t`t`t: "         $Theme.UserPortal.LanguageBar.en_US.ToString()
                                    Line 3 "German`t`t`t: "          $Theme.UserPortal.LanguageBar.de_DE.ToString()
                                    Line 3 "Japanese`t`t: "          $Theme.UserPortal.LanguageBar.ja_JP.ToString()
                                    Line 3 "Russian`t`t`t: "         $Theme.UserPortal.LanguageBar.ru_RU.ToString()
                                    Line 3 "French`t`t`t: "          $Theme.UserPortal.LanguageBar.fr_FR.ToString()
                                    Line 3 "Spanish`t`t`t: "         $Theme.UserPortal.LanguageBar.es_ES.ToString()
                                    Line 3 "Italian`t`t`t: "         $Theme.UserPortal.LanguageBar.it_IT.ToString()
                                    Line 3 "Portuguese`t`t: "        $Theme.UserPortal.LanguageBar.pt_BR.ToString()
                                    Line 3 "Chinese Simplified`t: "  $Theme.UserPortal.LanguageBar.zh_CN.ToString()
                                    Line 3 "Chinese Traditional`t: " $Theme.UserPortal.LanguageBar.zh_TW.ToString()
                                    Line 3 "Korean`t`t`t: "          $Theme.UserPortal.LanguageBar.ko_KR.ToString()
                                    Line 3 "Dutch`t`t`t: "           $Theme.UserPortal.LanguageBar.nl_NL.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Default language",($Script:htmlsb),$Theme.UserPortal.LanguageBar.Default.ToString(),$htmlwhite)
                                    $rowdata += @(,("English"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.en_US.ToString(),$htmlwhite))
                                    $rowdata += @(,("German"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.de_DE.ToString(),$htmlwhite))
                                    $rowdata += @(,("Japanese"           ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ja_JP.ToString(),$htmlwhite))
                                    $rowdata += @(,("Russian"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ru_RU.ToString(),$htmlwhite))
                                    $rowdata += @(,("French"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.fr_FR.ToString(),$htmlwhite))
                                    $rowdata += @(,("Spanish"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.es_ES.ToString(),$htmlwhite))
                                    $rowdata += @(,("Italian"            ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.it_IT.ToString(),$htmlwhite))
                                    $rowdata += @(,("Portuguese"         ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.pt_BR.ToString(),$htmlwhite))
                                    $rowdata += @(,("Chinese Simplified" ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.zh_CN.ToString(),$htmlwhite))
                                    $rowdata += @(,("Chinese Traditional",($Script:htmlsb),$Theme.UserPortal.LanguageBar.zh_TW.ToString(),$htmlwhite))
                                    $rowdata += @(,("Korean"             ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.ko_KR.ToString(),$htmlwhite))
                                    $rowdata += @(,("Dutch"              ,($Script:htmlsb),$Theme.UserPortal.LanguageBar.nl_NL.ToString(),$htmlwhite))
 
  <>                                 $msg = "User Portal (Web client)/Language bar"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                WriteWordLine 3 0 "Sites"                                   WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Messages"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Messages"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
 
  <>  
                                $cnt =-1                                   $cnt = -1
                                ForEach($Site in $PubItem.PublishToSite)                                   ForEach($line in $ThemeUserPortalPrelogonMessage)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name +-  
 
                                                $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "Pre-logon message:"; Value = $line; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
                                WriteWordLine 3 0 "Publish from" +-  
 
                                If($PubItem.PublishFrom -eq "Server") <>                                 $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.UserPortal.Message.OverridePostLogonMessage.ToString(); }) > $Null
                                    If($Theme.UserPortal.Message.OverridePostLogonMessage)
 
                                        $cnt = -1 <>  
                                        ForEach($Item in $PubItem.PublishFromServer)                                           ForEach($line in $ThemeUserPortalPostlogonMessage)
 
                                                $cnt++ <>  
                                                    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null
                                                }    
 
                                } +-  
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null    
                                                }    
                                                Else    
                                                {    
                                                        $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = ""; }) > $Null    
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                         }
                                WriteWordLine 3 0 "Application"    
                                WriteWordLine 4 0 "Application"    
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null    
                            If($Text)
                                $Table = AddWordTable -Hashtable $ScriptInformation `    
                                -Columns Data,Value `    
                                -List `    
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
                            {
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
                                    $cnt = -1
                                $Table.Columns.Item(1).Width = 200;                                   ForEach($line in $ThemeUserPortalPrelogonMessage)
                                $Table.Columns.Item(2).Width = 300;    
                                    {
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
                                            $cnt++
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""    
                                                                          
                                WriteWordLine 4 0 "Server settings"                                           If($cnt -eq 0)
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Start in"; Value = $PubItem.StartIn; }) > $Null    
                                $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null    
                                            {
                                $Table = AddWordTable -Hashtable $ScriptInformation `                                                   Line 3 "Pre-logon message: " $line
                                -Columns Data,Value `    
                                -List `                                           }
                                -Format $wdTableGrid `    
                                -AutoFit $wdAutoFitFixed;    
                                            Else
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
                                            {
                                $Table.Columns.Item(1).Width = 200;                                                   Line 5 "    " $line
                                $Table.Columns.Item(2).Width = 300;    
                                            }
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
                                    }
                                FindWordDocumentEnd    
                                $Table = $Null    
                                WriteWordLine 0 0 ""                                   Line 0 ""
                                    
                                OutputPubItemFilters $PubItem "MSWordPDF"                                   Line 3 "Override post-logon message: " $Theme.UserPortal.Message.OverridePostLogonMessage.ToString()
                                    If($Theme.UserPortal.Message.OverridePostLogonMessage)
                                                                  {
                                OutputPubItemShortcuts $PubItem "MSWordPDF" `                                           ForEach($line in $ThemeUserPortalPostlogonMessage)
                                $DefaultCreateShortcutOnDesktop `                                           {
                                $DefaultCreateShortcutInStartFolder `                                                   Line 5 "    " $line
                                $DefaultStartPath `                                           }
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
                                    }
                                WriteWordLine 3 0 "File extensions"                                   Line 0 ""
                                $ScriptInformation = New-Object System.Collections.ArrayList    
                                $ScriptInformation.Add(@{Data = "Associate File Extensions"; Value = $PubItem.EnableFileExtensions.ToString(); }) > $Null    
                            }
                                If($PubItem.EnableFileExtensions)                           If($HTML)
                                {                           {
                                    $rowdata = @()
                                        $cnt = -1                                   $cnt = -1
                                        ForEach($Item in $PubItem.FileExtensions)                                   ForEach($line in $ThemeUserPortalPrelogonMessage)
                                        {                                   {
                                                $cnt++                                           $cnt++
                                                                                          
                                                If($cnt -eq 0)                                           If($cnt -eq 0)
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = "Extension"; Value = $Item; }) > $Null                                                   $columnHeaders = @("Pre-logon message:",($Script:htmlsb),$line,$htmlwhite)
                                                }                                           }
                                                Else                                           Else
                                                {                                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null                                                   $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))
                                                }                                           }
                                    }
     
                                    $msg = "User Portal (Web client)/Messages"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    $rowdata = @()
                                    $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.UserPortal.Message.OverridePostLogonMessage.ToString(),$htmlwhite)
                                    If($Theme.UserPortal.Message.OverridePostLogonMessage)
                                    {
                                            ForEach($line in $ThemeUserPortalPostlogonMessage)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))
 
                                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateFileExtensionSettings.ToString(); }) > $Null <>  
                                    $msg = ""
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
 
  <>                         If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Input prompt"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Input prompt"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            $InputPromptTable = @()
                            
                            $InputPromptTable += @{
                                    Language = "German"
                                    LoginHint = $Theme.UserPortal.InputPrompt.de_DE.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.de_DE.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "English"
                                    LoginHint = $Theme.UserPortal.InputPrompt.en_US.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.en_US.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Japanese"
                                    LoginHint = $Theme.UserPortal.InputPrompt.ja_JP.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.ja_JP.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Russian"
                                    LoginHint = $Theme.UserPortal.InputPrompt.ru_RU.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.ru_RU.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "French"
                                    LoginHint = $Theme.UserPortal.InputPrompt.fr_FR.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.fr_FR.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Spanish"
                                    LoginHint = $Theme.UserPortal.InputPrompt.es_ES.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.es_ES.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Italian"
                                    LoginHint = $Theme.UserPortal.InputPrompt.it_IT.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.it_IT.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Portuguese"
                                    LoginHint = $Theme.UserPortal.InputPrompt.pt_BR.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.pt_BR.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Chinese Simplified"
                                    LoginHint = $Theme.UserPortal.InputPrompt.zh_CN.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.zh_CN.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Chinese Traditional"
                                    LoginHint = $Theme.UserPortal.InputPrompt.zh_TW.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.zh_TW.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Korean"
                                    LoginHint = $Theme.UserPortal.InputPrompt.ko_KR.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.ko_KR.PasswordHint
                            }
     
                            $InputPromptTable += @{
                                    Language = "Dutch"
                                    LoginHint = $Theme.UserPortal.InputPrompt.nl_NL.LoginHint
                                    PasswordHint = $Theme.UserPortal.InputPrompt.nl_NL.PasswordHint
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    If($InputPromptTable.Count -gt 0)
                                    {
                                $Table = AddWordTable -Hashtable $ScriptInformation `                                           $Table = AddWordTable -Hashtable $InputPromptTable `
                                -Columns Data,Value `                                           -Columns Language, LoginHint, PasswordHint `
                                -List `                                           -Headers "Language", "Login hint", "Password hint" `
                                -Format $wdTableGrid `                                           -Format $wdTableGrid `
                                -AutoFit $wdAutoFitFixed;                                           -AutoFit $wdAutoFitFixed;
 
                                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                         SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                           SetWordCellFormat -Collection $Table.Rows.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
  <>                                         $Table.Columns.Item(1).Width = 100;
                                $Table.Columns.Item(1).Width = 200;                                           $Table.Columns.Item(2).Width = 100;
                                $Table.Columns.Item(2).Width = 300;                                           $Table.Columns.Item(3).Width = 100;
                                            
                                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)                                           $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                                FindWordDocumentEnd <>                                         FindWordDocumentEnd
                                $Table = $Null                                           $Table = $Null
                                WriteWordLine 0 0 ""                                           WriteWordLine 0 0 ""
                                    }
                            }
                            If($Text)
                            {
                                WriteWordLine 3 0 "License"                                   Line 3 "Language             Login hint           Password hint"
                                $ScriptInformation = New-Object System.Collections.ArrayList                                   Line 3 "======================================================="
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $PubItem.InheritLicenseDefaultSettings.ToString(); }) > $Null                                   #       1234567890123456789SS1234567890123456789SS1234567890123
                                    #               Chinese Traditional  utilisateur@domaine  mot de passe
                                    #                            ユーザー@ドメイン
 
                                If($PubItem.InheritLicenseDefaultSettings) <>                                 ForEach($Item in $InputPromptTable)
 
                                        $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $DefaultDisableSessionSharing ; }) > $Null <>                                         Line 3 ( "{0,-19}  {1,-19}  {2,-13}" -f
                                                    $Item.Language, 
                                                    $Item.LoginHint, 
                                                    $Item.PasswordHint
                                            )
                                    }
                                    
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
     
                                        If($DefaultOneInstancePerUser)                                   ForEach($Item in $InputPromptTable)
                                        {                                   {
                                            $rowdata += @(,(
                                                    $Item.Language,$htmlwhite,
                                                    $Item.LoginHint,$htmlwhite,
                                                    $Item.PasswordHint,$htmlwhite)
                                            )
                                    }
                                    
                                    $columnHeaders = @(
                                            "Language",($Script:htmlsb),
                                            "Login hint",($Script:htmlsb),
                                            "Pasword hint",($Script:htmlsb)
                                    )
     
                                    $msg = "User Portal (Web client)/Input prompt"
                                    $columnWidths = @("110","120","100")
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                        }                           }
                                        Else    
                            If($MSWord -or $PDF)
                                        {                           {
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null                                   WriteWordLine 4 0 "User Portal (Web client)/Secure Gateway"
                                        }                           }
                                        $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $DefaultConCurrentLicenses; }) > $Null                           If($Text)
                                        $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $DefaultLicenseLimitNotify; }) > $Null                           {
                                    Line 2 "User Portal (Web client)/Secure Gateway"
                                }                           }
                            If($HTML)
                                Else                           {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                                {                           {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Override Secure Gateway settings for theme"; Value = $Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Client"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $SessionSharing; }) > $Null                                   $ScriptInformation.Add(@{Data = "     Launch sessions using"; Value = $ThemeUserPortalLaunchSessionsUsing; }) > $Null
                                        If($PubItem.OneInstancePerUser)                                   Switch($Theme.UserPortal.Gateway.LaunchMethod)
                                    {
                                            "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"  
 
  <>                                                 $ScriptInformation.Add(@{Data = "     Allow user to select a launch method"; Value = $Theme.UserPortal.Gateway.AllowLaunchMethod.ToString(); }) > $Null
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(); }) > $Null
                                                    Break
 
  <>                                         "Launch_Applications_with_Parallels_Client"                                             
                                        Else                                           {
                                                    Break
                                            }
                                            "Launch_Applications_with_Browser_HTML5"                                                
 
                                                $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = "     Allow opening applications in a new tab"; Value = $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(); }) > $Null
                                                    Break
 
                                        $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $ConCurrentLicenses; }) > $Null +-  
                                        $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $LicenseLimitNotify; }) > $Null    
 
                                If($PubItem.InheritLicenseDefaultSettings) <>                                 $ScriptInformation.Add(@{Data = "     Use Pre Windows 2000 login format"; Value = $Theme.UserPortal.Gateway.Pre2000Cred.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow embedding of User Portal into other web pages"; Value = $Theme.UserPortal.Gateway.AllowEmbed.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow file transfer command"; Value = $ThemeHTMLFileTransfer; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow clipboard command"; Value = $ThemeHTMLClipboardDirection; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Allow cross-origin resource sharing"; Value = $Theme.UserPortal.Gateway.AllowCORS.ToString(); }) > $Null
                                    If($Theme.UserPortal.Gateway.AllowCORS)
 
  <>                                         $cnt=-1
                                            ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateLicenseSettings.ToString(); }) > $Null                                                           $ScriptInformation.Add(@{Data = "Allow domains"; Value = $Domain; }) > $Null
                                }                                                   }
                                Else                                                   Else
                                {                                                   {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $Domain; }) > $Null
                                                    }
                                            }
                                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateLicenseSettings.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "Browser cache time"; Value = "$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months"; }) > $Null
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  <>                         }
                            If($Text)
                            {
                                    Line 3 "Override Secure Gateway settings for theme: " $Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString()
                                WriteWordLine 3 0 "Display"                                   Line 3 "Client"
                                $ScriptInformation = New-Object System.Collections.ArrayList                                   Line 4 "Launch sessions using`t`t`t: " $ThemeUserPortalLaunchSessionsUsing
                                    Switch($Theme.UserPortal.Gateway.LaunchMethod)
                                    {
                                            "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"  
                                            {
                                                    Line 4 "Allow user to select a launch method`t: " $Theme.UserPortal.Gateway.AllowLaunchMethod.ToString()
                                $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $PubItem.InheritDisplayDefaultSettings.ToString(); }) > $Null                                                   Line 4 "Allow opening applications in a new tab`t: " $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString()
                                                    Break
                                            }
                                If($PubItem.InheritDisplayDefaultSettings)                                           "Launch_Applications_with_Parallels_Client"                                             
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "Wait until all RAS Universal Printers are redirected before showing the application"; Value = $DefaultWaitForPrinters; }) > $Null                                                   Break
                                        $ScriptInformation.Add(@{Data = "Maximum time to wait is"; Value = "$($DefaultWaitForPrintersTimeout) seconds"; }) > $Null                                           }
                                        $ScriptInformation.Add(@{Data = "Color Depth"; Value = $DefaultColorDepth; }) > $Null                                           "Launch_Applications_with_Browser_HTML5"                                               
                                        $ScriptInformation.Add(@{Data = "Start the application as maximized when using mobile clients"; Value = $DefaultStartMaximized; }) > $Null                                           {
                                                    Line 4 "Allow opening applications in a new tab`t: " $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString()
                                                    Break
                                            }
 
  <>                                 Line 4 "Use Pre Windows 2000 login format`t: " $Theme.UserPortal.Gateway.Pre2000Cred.ToString()
                                    Line 4 "Allow embedding of User Portal "
                                    Line 4 "Client into other web pages`t`t: " $Theme.UserPortal.Gateway.AllowEmbed.ToString()
                                    Line 4 "Allow file transfer command`t`t: " $ThemeHTMLFileTransfer
                                    Line 4 "Allow clipboard command`t`t`t: " $ThemeHTMLClipboardDirection
                                    Line 4 "Allow cross-origin resource sharing`t: " $Theme.UserPortal.Gateway.AllowCORS.ToString()
                                    If($Theme.UserPortal.Gateway.AllowCORS)
                                    {
                                            $cnt=-1
                                            ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            Line 5 "Allow domains`t`t`t: " $Domain
                                                    }
                                Else                                                   Else
                                {                                                   {
                                                            Line 9 "  " $Domain
                                                    }
                                            }
                                            Line 5 "Browser cache time`t`t: "  "$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months"
                                    }
     
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                        $ScriptInformation.Add(@{Data = "Wait until all RAS Universal Printers are redirected before showing the application"; Value = $PubItem.WaitForPrinters.ToString(); }) > $Null                                   $columnHeaders = @("Override Secure Gateway settings for theme",($Script:htmlsb),$Theme.UserPortal.Gateway.OverrideGatewaySettings.ToString(),$htmlwhite)
                                    $rowdata += @(,("Client",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Launch sessions using",($Script:htmlsb),$ThemeUserPortalLaunchSessionsUsing,$htmlwhite))
                                    Switch($Theme.UserPortal.Gateway.LaunchMethod)
                                    {
                                            "Launch_Applications_with_Parallels_Client_Fallback_to_HTML_5"  
                                            {
                                        $ScriptInformation.Add(@{Data = "Maximum time to wait is"; Value = "$($PubItem.WaitForPrintersTimeout.ToString()) seconds"; }) > $Null                                                   $rowdata += @(,("     Allow user to select a launch method",($Script:htmlsb),$Theme.UserPortal.Gateway.AllowLaunchMethod.ToString(),$htmlwhite))
                                        $ScriptInformation.Add(@{Data = "Color Depth"; Value = $ColorDepth; }) > $Null    
                                        $ScriptInformation.Add(@{Data = "Start the application as maximized when using mobile clients"; Value = $PubItem.StartMaximized.ToString(); }) > $Null                                                   $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))
                                                    Break
                                }                                           }
                                If($PubItem.InheritDisplayDefaultSettings)                                           "Launch_Applications_with_Parallels_Client"                                             
                                {                                           {
                                                    Break
                                            }
                                            "Launch_Applications_with_Browser_HTML5"                                                
                                            {
                                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateDisplaySettings.ToString(); }) > $Null                                                   $rowdata += @(,("     Allow opening applications in a new tab",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowAppsInNewTab.ToString(),$htmlwhite))
                                                    Break
                                            }
 
  <>                                 $rowdata += @(,("     Use Pre Windows 2000 login format",($Script:htmlsb), $Theme.UserPortal.Gateway.Pre2000Cred.ToString(),$htmlwhite))
                                    $rowdata += @(,("     Allow embedding of User Portal into other web pages",($Script:htmlsb), $Theme.UserPortal.Gateway.AllowEmbed.ToString(),$htmlwhite))
                                    $rowdata += @(,("     Allow file transfer command",($Script:htmlsb),$ThemeHTMLFileTransfer,$htmlwhite))
                                    $rowdata += @(,("     Allow clipboard command",($Script:htmlsb),$ThemeHTMLClipboardDirection,$htmlwhite))
                                    $rowdata += @(,("     Allow cross-origin resource sharing",($Script:htmlsb),$Theme.UserPortal.Gateway.AllowCORS.ToString(),$htmlwhite))
                                    If($Theme.UserPortal.Gateway.AllowCORS)
                                    {
                                            $cnt=-1
                                            ForEach($Domain in $Theme.UserPortal.Gateway.AllowedDomainsForCORS)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $rowdata += @(,("Allow domains",($Script:htmlsb),$Domain,$htmlwhite))
                                                    }
                                Else                                                   Else
                                {                                                   {
                                                            $rowdata += @(,("",($Script:htmlsb),$Domain,$htmlwhite))
                                                    }
                                            }
                                            $rowdata += @(,("Browser cache time",($Script:htmlsb),"$($Theme.UserPortal.Gateway.BrowserCacheTimeInMonths.ToString()) months",$htmlwhite))
                                    }
     
                                    $msg = "User Portal (Web client)/Secure Gateway"
                                    $columnWidths = @("300","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "User Portal (Web client)/Legal policies"
                            }
                            If($Text)
                            {
                                    Line 2 "User Portal (Web client)/Legal policies"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Cookie consent"; Value = ""; }) > $Null
                                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateDisplaySettings.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "     Enable cookie consent"; Value = $Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "End User License Agreement"; Value = ""; }) > $Null
                                    $ScriptInformation.Add(@{Data = "     Enable EULA"; Value = $Theme.UserPortal.LegalPolicies.AllowEULA.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Cookie consent" 
                                    Line 4 "Enable cookie consent`t: " $Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString()
                                    Line 3 "End User License Agreement" 
                                    Line 4 "Enable EULA`t`t: " $Theme.UserPortal.LegalPolicies.AllowEULA.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Cookie consent",($Script:htmlsb),"",$htmlwhite)
                                    $rowdata += @(,("     Enable cookie consent",($Script:htmlsb),$Theme.UserPortal.LegalPolicies.AllowCookieConsent.ToString(),$htmlwhite))
                                    $rowdata += @(,("End User License Agreement",($Script:htmlsb),"",$htmlwhite))
                                    $rowdata += @(,("     Enable EULA",($Script:htmlsb), $Theme.UserPortal.LegalPolicies.AllowEULA.ToString(),$htmlwhite))
     
                                    $msg = "User Portal (Web client)/Legal policies"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Windows client/Branding"
                            }
                            If($Text)
                            {
                                    Line 2 "Windows client/Branding"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Company name"; Value = $Theme.WindowsClient.Branding.CompanyName; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Application name"; Value = $Theme.WindowsClient.Branding.ApplicationName; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Connection banner"; Value = $ThemeConnectionBanner; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Application icon"; Value = $ThemeApplicationIcon; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Company name`t`t: " $Theme.WindowsClient.Branding.CompanyName
                                    Line 3 "Application name`t: " $Theme.WindowsClient.Branding.ApplicationName
                                    Line 3 "Connection banner`t: " $ThemeConnectionBanner
                                    Line 3 "Application icon`t: " $ThemeApplicationIcon
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Company name",($Script:htmlsb),$Theme.WindowsClient.Branding.CompanyName,$htmlwhite)
                                    $rowdata += @(,("Application name",($Script:htmlsb),$Theme.WindowsClient.Branding.ApplicationName,$htmlwhite))
                                    $rowdata += @(,("Connection banner",($Script:htmlsb),$ThemeConnectionBanner,$htmlwhite))
                                    $rowdata += @(,("Application icon",($Script:htmlsb),$ThemeApplicationIcon,$htmlwhite))
     
                                    $msg = "Windows client/Branding"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Windows client/Messages"
                            }
                            If($Text)
                            {
                                    Line 2 "Windows client/Messages"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Override post-logon message"; Value = $Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString(); }) > $Null
                                    If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)
                                    {
                                            ForEach($line in $ThemeWindowsPostlogonMessage)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $line; }) > $Null
                                            }
 
                                $Table.Columns.Item(2).Width = 300; <>                                 $Table.Columns.Item(2).Width = 250;
 
  -+                                 WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 3 "Override post-logon message: " $Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString()
                                    If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)
                                    {
                                            ForEach($line in $ThemeWindowsPostlogonMessage)
                                            {
                                                    Line 5 "    " $line
                                            }
                                    }
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Override post-logon message",($Script:htmlsb),$Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage.ToString(),$htmlwhite)
                                    If($Theme.WindowsClient.Messages.WindowsClientOverridePostLogonMessage)
                                    {
                                            ForEach($line in $ThemeWindowsPostlogonMessage)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$line,$htmlwhite))
                                            }
                                    }
 
  -+                                 $msg = "Windows client/Messages"
                                    $columnWidths = @("200","400")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "Windows client/Custom menu"
                            }
                            If($Text)
                            {
                                    Line 2 "Windows client/Custom menu"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Menu item"; Value = $Theme.WindowsClient.CustomMenu.MenuItem; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Command"; Value = $Theme.WindowsClient.CustomMenu.Command; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
 
  <>                                 Line 3 "Menu item: " $Theme.WindowsClient.CustomMenu.MenuItem
                                    Line 3 "Command`t : " $Theme.WindowsClient.CustomMenu.Command
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $rowdata = @()
                                    $columnHeaders = @("Menu item",($Script:htmlsb),$Theme.WindowsClient.CustomMenu.MenuItem,$htmlwhite)
                                    $rowdata += @(,("Command",($Script:htmlsb),$Theme.WindowsClient.CustomMenu.Command,$htmlwhite))
     
                                    $msg = "Windows client/Custom menu"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
     
            #Certificates
     
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Certificates"
            }
            If($Text)
            {
                                Line 2 "Information"                   Line 1 "Certificates"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Certificates"
            }
     
            $Certs = Get-RASCertificate -Siteid $Site.Id -EA 0 4> $Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Certificates for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Certificates for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $Certs)
            {
                    Write-Host "
                    No Certificates retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Certificates retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Certificates"
                    ForEach($Cert in $Certs)
                    {
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Certificate $($Cert.Name)"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $Cert.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Status"; Value = $Cert.Status.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Expiration date"; Value = $Cert.ExpirationDate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Common name"; Value = $Cert.CommonName; }) > $Null
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Alternate Names"; Value = $Item; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $Cert.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $Cert.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $Cert.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $Cert.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "ID"; Value = $Cert.Id.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                    Line 2 "Certificate $($Cert.Name)"
                                    Line 3 "Name`t`t`t: " $Cert.Name
                                Line 3 "Application`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"                                   Line 3 "Status`t`t`t: " $Cert.Status.ToString()
                                Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description                                   Line 3 "Expiration date`t`t: " $Cert.ExpirationDate
                                    Line 3 "Usage`t`t`t: " $Cert.Usage
                                    Line 3 "Common name`t`t: " $Cert.CommonName
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Alternate Names`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 6 "  " $Item
                                            }
                                    }
                                    
                                Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod                                   Line 3 "Last modification by`t: " $Cert.AdminLastMod
                                Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()                                   Line 3 "Modified on`t`t: " $Cert.TimeLastMod.ToString()
                                Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate                                   Line 3 "Created by`t`t: " $Cert.AdminCreate
                                Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()                                   Line 3 "Created on`t`t: " $Cert.TimeCreate.ToString()
                                    Line 3 "ID`t`t`t: " $Cert.Id.ToString()
                                    Line 0 ""
                            }
                            If($HTML)
                            {
                                    $CertName = $Cert.Name.Replace("<","").Replace(">","")
                                    WriteHTMLLine 3 0 "Certificate $CertName"
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$CertName,$htmlwhite)
                                    $rowdata += @(,("Status",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))
                                    $rowdata += @(,("Expiration date",($Script:htmlsb),$Cert.ExpirationDate,$htmlwhite))
                                    $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))
                                    $rowdata += @(,("Common name",($Script:htmlsb),$Cert.CommonName,$htmlwhite))
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("Alternate Names",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $Cert.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $Cert.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $Cert.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $Cert.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("ID",($Script:htmlsb),$Cert.Id.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 4 0 "General"
                            }
                            If($Text)
                            {
                                    Line 2 "General"
                            }
                            If($HTML)
                            {
                                    #Nothing
                            }
                            
                            Switch($Cert.KeySize)
                            {
                                    "KeySize1024"           {$KeySize = "1024"; Break}
                                    "KeySize2048"           {$KeySize = "2048"; Break}
                                    "KeySize4096"           {$KeySize = "4096"; Break}
                                    "KeySizeUnknown"        {$KeySize = ""; Break}
                                    Default                         {$KeySize = "Unable to determine certificate key size: $($Cert.KeySize)"; Break}
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $Cert.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $Cert.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Usage"; Value = $Cert.Usage; }) > $Null
                                    $ScriptInformation.Add(@{Data = "State"; Value = $Cert.Status.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Key size"; Value = $KeySize; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Expiration date"; Value = $Cert.ExpirationDate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Common name"; Value = $Cert.CommonName; }) > $Null
                                    
                                    $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
                                    {
                                            $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Alternate Names"; Value = $Item; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 250;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                            }
                            If($Text)
                            {
                                Line 3 "Status`t`t`t`t`t`t`t: " $PubItemMode                                   Line 3 "Name`t`t`t: " $Cert.Name
                                    Line 3 "Description`t`t: " $Cert.Description
                                Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target                                   Line 3 "Usage`t`t`t: " $Cert.Usage
                                Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn                                   Line 3 "State`t`t`t: " $Cert.Status.ToString()
                                Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()                                   Line 3 "Key size`t`t: " $KeySize
                                    Line 3 "Expiration date`t`t: " $Cert.ExpirationDate
                                    Line 3 "Common name`t`t: " $Cert.CommonName
 
                                If(![String]::IsNullOrEmpty($PubItem.Parameters)) <>                                 $cnt=-1
                                    ForEach($Item in $Cert.AlternateNames)
 
  <>                                         $cnt++
                                            
                                            If($cnt -eq 0)
                                            {
                                        Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters                                                   Line 3 "Alternate Names`t`t: " $Item
                                            }
                                            Else
                                            {
                                                    Line 6 "  " $Item
                                            }
 
                                If($PubItem.EnableFileExtensions) <>                                 Line 0 ""
                            }
                            If($HTML)
                                {                           {
                                        Line 3 "Associate the following file extensions"                                   $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$Cert.Name.Replace("<","").Replace(">",""),$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$Cert.Description,$htmlwhite))
                                    $rowdata += @(,("Usage",($Script:htmlsb),$Cert.Usage,$htmlwhite))
                                    $rowdata += @(,("State",($Script:htmlsb),$Cert.Status.ToString(),$htmlwhite))
                                    $rowdata += @(,("Key size",($Script:htmlsb),$KeySize,$htmlwhite))
                                    $rowdata += @(,("Expiration date",($Script:htmlsb),$Cert.ExpirationDate,$htmlwhite))
                                    $rowdata += @(,("Common name",($Script:htmlsb),$Cert.CommonName,$htmlwhite))
                                    
                                    $cnt=-1
                                        ForEach($Item in $PubItem.FileExtensions)                                   ForEach($Item in $Cert.AlternateNames)
                                        {                                   {
                                            $cnt++
                                            
                                                Line 10 "  " $Item                                           If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("Alternate Names",($Script:htmlsb),$Item,$htmlwhite))
 
  -+                                         Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
 
  <>                                 $msg = "General"
                                    $columnWidths = @("200","275")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                            }
                    }
            }
     
            #Settings
            
            #Auditing - not in PoSH
     
            #Global logging - not in PoSH
     
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Settings"
            }
            If($Text)
            {
                    Line 1 "Settings"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Settings"
            }
     
            $FarmSettings = Get-RASFarmSettings -SiteId $Site.Id -ea 0 4>$Null
            
            If(!$?)
            {
                    Write-Warning "
                    `n
                                If($PubItem.InheritLicenseDefaultSettings)                   Unable to retrieve Settings for Site $($Site.Name)`
                    "
                    If($MSWord -or $PDF)
                                {                   {
                            WriteWordLine 0 0 "Unable to retrieve Settings for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Settings for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Settings for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $Null -eq $FarmSettings)
            {
                    Write-Host "
                    No Settings retrieved for Site $($Site.Name).`
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Settings retrieved for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Settings retrieved for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Settings retrieved for Site $($Site.Name)"
                    }
            }
            Else
            {
                    Write-Verbose "$(Get-Date -Format G): `t`tOutput Settings"
            }
            
            <#RASFarmSettings       
                    Dropped Properties      ExcludeDirectRDP
                                                            ExcludeDirectRDPForVDI
                                                            SendHDIcons
                                                            ReplicateSendHDIcons
                                                            EnableOverlayIcons
                                                            ShowPasswordExpiry
                                                            ReplicateURLRedirection
                                                            URLBlackList
                                                            TokenValidationTime
     
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "URL redirection"
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Do not redirect the following URLs"; Value = ""; }) > $Null
                    $cnt = -1
                    ForEach($Item in $FarmSettings.URLBlacklist)
                    {
                            $cnt++
                            
                            If($Cnt -eq 0)
                            {
                                    $ScriptInformation.Add(@{Data = "     Url"; Value = $Item; }) > $Null
                            }
                            Else
                            {
                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                            }
                    }
                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sitess"; Value = $FarmSettings.ReplicateURLRedirection.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 200;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "URL redirection"
                    Line 3 "Do not redirect the following URLs`t: "
                    $cnt = -1
                    ForEach($Item in $FarmSettings.URLBlacklist)
                    {
                            $cnt++
                            
                            If($Cnt -eq 0)
                            {
                                    Line 7 "     Url: " $Item
                            }
                            Else
                            {
                                    Line 8 "  " $Item
                            }
                    }
                                        Line 3 "Allow users to start only 1 instance of this application: " $DefaultOneInstancePerUser.ToString()                   Line 3 "Settings are replicated to all Sites`t: " $FarmSettings.ReplicateURLRedirection.ToString()
                    Line 0 ""
            }
            If($HTML)
            {
                    WriteHTMLLine 3 0 "URL redirection"
                    $rowdata = @()
                    $columnHeaders = @("Do not redirect the following URLs",($Script:htmlsb),"",$htmlwhite)
                    $cnt = -1
                    ForEach($Item in $FarmSettings.URLBlacklist)
                    {
                            $cnt++
                            
                            If($Cnt -eq 0)
                            {
                                    $rowdata += @(,("     URL",($Script:htmlsb),$Item,$htmlwhite))
                            }
                            Else
                            {
                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                            }
                    }
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FarmSettings.ReplicateURLRedirection.ToString(),$htmlwhite))
     
                    $msg = ""
                    $columnWidths = @("200","275")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                    WriteHTMLLine 0 0 ""
            }
            #>      
            $RASNotificationHandlers = Get-RASNotification -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve notification handlers information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve notification handlers information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve notification handlers information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve notification handlers information"
                    }
            }
            ElseIf($? -and $null -eq $RASNotificationHandlers)
            {
                    Write-Host "
                    No notification handlers information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No notification handlers information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No notification handlers information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No notification handlers information was found"
                    }
            }
            Else
            {
                    OutputRASNotifications $RASNotificationHandlers
            }
            
            $RASNotificationScripts = Get-RASNotificationScript -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve notification scripts information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve notification scripts information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve notification scripts information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve notification scripts information"
                    }
            }
            ElseIf($? -and $null -eq $RASNotificationScripts)
            {
                    Write-Host "
                    No notification scripts information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No notification scripts information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No notification scripts information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No notification scripts information was found"
                    }
            }
            Else
            {
                    OutputRASNotificationScripts $RASNotificationScripts
            }
            
            $RASClientSettings = Get-RASClientSettings -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve CLient Settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve CLient Settings information"
                    }
                    If($Text)
                    {
                                        Line 3 "Concurrent licenses`t`t`t`t`t: " $DefaultConCurrentLicenses                           Line 0 "Unable to retrieve CLient Settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve CLient Settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASClientSettings)
            {
                    Write-Host "
                    No CLient Settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No CLient Settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No CLient Settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No CLient Settings information was found"
                    }
            }
            Else
            {
                    OutputRASClientSettings $RASClientSettings
            }
     
            $FSLogixDeploymentSettings = Get-RASFSLogixSettings -EA 0 4>$Null | Where-Object{ $_.SiteId -eq $Site.Id}
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve FSLogix Settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve FSLogix Settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve FSLogix Settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve FSLogix Settings information"
                    }
            }
            ElseIf($? -and $null -eq $FSLogixDeploymentSettings)
            {
                    Write-Host "
                    No FSLogix Settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No FSLogix Settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No FSLogix Settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No FSLogix Settings information was found"
                    }
            }
            Else
            {
                    Switch($FSLogixDeploymentSettings.InstallType)
                    {
                            "Manually"              {$FSLogixDeploymentSettingsDeploymentMethod = "Install manually"; Break}
                            "Online"                {$FSLogixDeploymentSettingsDeploymentMethod = "Install online"; Break}
                            "NetworkDrive"  {$FSLogixDeploymentSettingsDeploymentMethod = "Install from a network share"; Break}
                            "UploadInstall" {$FSLogixDeploymentSettingsDeploymentMethod = "Push from RAS Publishing Agent"; Break}
                            Default                 {$FSLogixDeploymentSettingsDeploymentMethod = "Unable to determine FSLogix Deployment method: $($FSLogixDeploymentSettings.InstallType)"; Break}
                    }
                    
                    $FSLogixDeploymentSettingsInstallOnlineURL  = $FSLogixDeploymentSettings.InstallOnlineURL
                    $FSLogixDeploymentSettingsNetworkDrivePath  = $FSLogixDeploymentSettings.NetworkDrivePath
                    $FSLogixDeploymentSettingsInstallerFileName = $FSLogixDeploymentSettings.InstallerFileName
                    $FSLogixDeploymentSettingsReplicate         = $FSLogixDeploymentSettings.Replicate
                    
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 3 0 "Features"
                            WriteWordLine 4 0 "FSLogix"
                            $ScriptInformation = New-Object System.Collections.ArrayList
                            $ScriptInformation.Add(@{Data = "Deployment method"; Value = $FSLogixDeploymentSettingsDeploymentMethod; }) > $Null
                            If($FSLogixDeploymentSettings.InstallType -eq "Online")
                            {
                                    $ScriptInformation.Add(@{Data = "URL"; Value = $FSLogixDeploymentSettingsInstallOnlineURL; }) > $Null
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                            {
                                    $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsNetworkDrivePath; }) > $Null
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                            {
                                    $ScriptInformation.Add(@{Data = ""; Value = $FSLogixDeploymentSettingsInstallerFileName; }) > $Null
                            }
                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $FSLogixDeploymentSettingsReplicate.ToString(); }) > $Null
                            
                            $Table = AddWordTable -Hashtable $ScriptInformation `
                            -Columns Data,Value `
                            -List `
                            -Format $wdTableGrid `
                            -AutoFit $wdAutoFitFixed;
     
                            SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                            SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                            $Table.Columns.Item(1).Width = 200;
                            $Table.Columns.Item(2).Width = 250;
     
                            $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                            FindWordDocumentEnd
                            $Table = $Null
                            WriteWordLine 0 0 ""
                    }
                    If($Text)
                    {
                            Line 2 "Features"
                            Line 3 "FSLogix"
                            Line 4 "Deployment method`t`t`t`t`t: " $FSLogixDeploymentSettingsDeploymentMethod
                            If($FSLogixDeploymentSettings.InstallType -eq "Online")
                            {
                                        Line 3 "If limit is exceeded`t`t`t`t`t: " $DefaultLicenseLimitNotify                                   Line 4 "URL`t`t`t`t`t`t`t: " $FSLogixDeploymentSettingsInstallOnlineURL
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                            {
                                    Line 11 ": " $FSLogixDeploymentSettingsNetworkDrivePath
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                            {
                                    Line 11 ": " $FSLogixDeploymentSettingsInstallerFileName
                            }
                                        Line 3 "Session Sharing`t`t`t`t`t`t: " $DefaultDisableSessionSharing                           Line 4 "Settings are replicated to all Sites`t`t`t: " $FSLogixDeploymentSettingsReplicate.ToString()
                                }                   }
                    If($HTML)
                    {
                            WriteHTMLLine 3 0 "Features"
                            $rowdata = @()
                            $columnHeaders = @("Deployment method",($Script:htmlsb),$FSLogixDeploymentSettingsDeploymentMethod,$htmlwhite)
                            If($FSLogixDeploymentSettings.InstallType -eq "Online")
                            {
                                    $rowdata += @(,("URL",($Script:htmlsb),$FSLogixDeploymentSettingsInstallOnlineURL,$htmlwhite))
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "NetworkDrive")
                            {
                                    $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsNetworkDrivePath,$htmlwhite))
                            }
                            ElseIf($FSLogixDeploymentSettings.InstallType -eq "UploadInstall")
                            {
                                    $rowdata += @(,("",($Script:htmlsb),$FSLogixDeploymentSettingsInstallerFileName,$htmlwhite))
                            }
                            $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$FSLogixDeploymentSettingsReplicate.ToString(),$htmlwhite))
                                            
                            $msg = "FSLogix"
                            $columnWidths = @("200","250")
                            FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                            WriteHTMLLine 0 0 ""
                    }
            }
    }
    #endregion
     
    #region process load balancing
    Function ProcessLoadBalancing
    {
            Param([object]$Site)
            
            Write-Verbose "$(Get-Date -Format G): Processing Load Balancing"
            
            OutputLoadBalancingSectionPage
            
            Write-Verbose "$(Get-Date -Format G): `tProcessing Load Balancing"
            
            $results = Get-RASLBSettings -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Load Balancing information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Load Balancing information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Load Balancing information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Load Balancing information"
                    }
            }
            ElseIf($? -and $null -eq $results)
            {
                    Write-Host "
                    No Load Balancing information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Load Balancing information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No Load Balancing information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Load Balancing information was found"
                    }
            }
                                Else           Else
                                {           {
                    OutputRASLBSettings $results
            }
            
            $results = Get-RASCPUOptimizationSettings -SiteId $Site.Id -EA 0 4>$Null
            
            If(!($?))
            {
            Write-Warning "
            `n
            Unable to retrieve CPU Optimization information
            "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve CPU Optimization information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve CPU Optimization information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve CPU Optimization information"
                    }
            }
            ElseIf($? -and $null -eq $results)
            {
                    Write-Host "
                    No CPU Optimization information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No CPU Optimization information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No CPU Optimization information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No CPU Optimization information was found"
                    }
            }
            Else
            {
                    OutputCPUOptimizationSettings $results
            }
    }
     
    Function OutputLoadBalancingSectionPage
    {
            If($MSWord -or $PDF)
            {
                    $Script:Selection.InsertNewPage()
                    WriteWordLine 1 0 "Load Balancing"
            }
            If($Text)
            {
                    Line 0 "Load Balancing"
            }
            If($HTML)
            {
                    WriteHTMLLine 1 0 "Load Balancing"
            }
    }
     
    Function OutputRASLBSettings
    {
            Param([object] $RASLBSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Load Balancing"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "Load Balancing"
            }
            If($Text)
            {
                    Line 1 "Load Balancing"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "Load Balancing"
            }
            
            Switch ($RASLBSettings.Method)
            {
                    "ResourceBased" {$RASLBSettingsMethod = "Resource Based"; Break}
                    "RoundRobin"    {$RASLBSettingsMethod = "Round Robin"; Break}
                    Default                 {$RASLBSettingsMethod = "Unable to determine Load balancing method: $($RASLBSettings.Method)"; Break}
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Method"; Value = $RASLBSettingsMethod; }) > $Null
                    $ScriptInformation.Add(@{Data = "Counters"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     User Sessions"; Value = $RASLBSettings.SessionsCounter; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Memory"; Value = $RASLBSettings.MemoryCounter; }) > $Null
                    $ScriptInformation.Add(@{Data = "     CPU"; Value = $RASLBSettings.CPUCounter; }) > $Null
                    $ScriptInformation.Add(@{Data = "Reconnect to disconnected sessions"; Value = $RASLBSettings.ReconnectDisconnect; }) > $Null
                    $ScriptInformation.Add(@{Data = "Reconnect sessions using client's IP address only"; Value = $RASLBSettings.ReconnectUsingIPOnly; }) > $Null
                                        Line 3 "Allow users to start only 1 instance of this application: " $PubItem.OneInstancePerUser.ToString()                   $ScriptInformation.Add(@{Data = "Limit each user to one session per desktop"; Value = $RASLBSettings.ReconnectUser; }) > $Null
                    $ScriptInformation.Add(@{Data = "Disable Microsoft RD Connection Broker"; Value = $RASLBSettings.DisableRDSLB; }) > $Null
                    $ScriptInformation.Add(@{Data = "Declare Agent dead if not responding for"; Value = "$($RASLBSettings.DeadTimeout) seconds"; }) > $Null
                    $ScriptInformation.Add(@{Data = "Agent Refresh Time"; Value = "$($RASLBSettings.RefreshTimeout) seconds"; }) > $Null
                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASLBSettings.Replicate.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 275;
                    $Table.Columns.Item(2).Width = 150;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "Method`t`t`t: " $RASLBSettingsMethod
                    Line 2 "Counters"
                                        Line 3 "Concurrent licenses`t`t`t`t`t: " $ConCurrentLicenses                   Line 3 "User Sessions`t: " $RASLBSettings.SessionsCounter
                                        Line 3 "If limit is exceeded`t`t`t`t`t: " $LicenseLimitNotify                   Line 3 "Memory`t`t: " $RASLBSettings.MemoryCounter
                    Line 3 "CPU`t`t: " $RASLBSettings.CPUCounter
                    Line 2 "Reconnect to disconnected sessions`t`t`t: " $RASLBSettings.ReconnectDisconnect
                    Line 2 "Reconnect sessions using client's IP address only`t: " $RASLBSettings.ReconnectUsingIPOnly
                    Line 2 "Limit each user to one session per desktop`t`t: " $RASLBSettings.ReconnectUser
                                        Line 3 "Session Sharing`t`t`t`t`t`t: " $SessionSharing                   Line 2 "Disable Microsoft RD Connection Broker`t`t`t: " $RASLBSettings.DisableRDSLB
                    Line 2 "Declare Agent dead if not responding for`t`t: " "$($RASLBSettings.DeadTimeout) seconds"
                    Line 2 "Agent Refresh Time`t`t`t`t`t: " "$($RASLBSettings.RefreshTimeout) seconds"
                    Line 2 "Settings are replicated to all Sites`t`t`t: " $RASLBSettings.Replicate.ToString()
                    Line 0 ""
                                }           }
            If($HTML)
            {
                    $rowdata = @()
                    $columnHeaders = @("Method",($Script:htmlsb),$RASLBSettingsMethod,$htmlwhite)
                    $rowdata += @(,("Counters",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     User Sessions",($Script:htmlsb),$RASLBSettings.SessionsCounter.ToString(),$htmlwhite))
                    $rowdata += @(,("     Memory",($Script:htmlsb),$RASLBSettings.MemoryCounter.ToString(),$htmlwhite))
                    $rowdata += @(,("     CPU",($Script:htmlsb),$RASLBSettings.CPUCounter.ToString(),$htmlwhite))
                    $rowdata += @(,("Reconnect to disconnected sessions",($Script:htmlsb),$RASLBSettings.ReconnectDisconnect.ToString(),$htmlwhite))
                    $rowdata += @(,("Reconnect sessions using client's IP address only",($Script:htmlsb),$RASLBSettings.ReconnectUsingIPOnly.ToString(),$htmlwhite))
                    $rowdata += @(,("Limit each user to one session per desktop",($Script:htmlsb),$RASLBSettings.ReconnectUser.ToString(),$htmlwhite))
                    $rowdata += @(,("Disable Microsoft RD Connection Broker",($Script:htmlsb),$RASLBSettings.DisableRDSLB.ToString(),$htmlwhite))
                    $rowdata += @(,("Declare Agent dead if not responding for",($Script:htmlsb),"$($RASLBSettings.DeadTimeout) seconds",$htmlwhite))
                    $rowdata += @(,("Agent Refresh Time",($Script:htmlsb),"$($RASLBSettings.RefreshTimeout) seconds",$htmlwhite))
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASLBSettings.Replicate.ToString(),$htmlwhite))
 
  <>                 $msg = ""
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
     
    Function OutputCPUOptimizationSettings
    {
            Param([object] $RASCPUSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput CPU Optimization"
            
            If($MSWord -or $PDF)
            {
                    WriteWordLine 2 0 "CPU Optimization"
            }
            If($Text)
            {
                    Line 1 "CPU Optimization"
            }
            If($HTML)
            {
                    WriteHTMLLine 2 0 "CPU Optimization"
            }
            
            If($MSWord -or $PDF)
            {
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Enable CPU Optimization"; Value = $RASCPUSettings.EnableCPUOptimization.ToString(); }) > $Null
                    $ScriptInformation.Add(@{Data = "Start"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Total CPU usage exceeds"; Value = "$($RASCPUSettings.StartUsage) %"; }) > $Null
                    $ScriptInformation.Add(@{Data = "CPU Conditions"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Critical - CPU usage by process exceeds"; Value = "$($RASCPUSettings.CriticalUsage) %"; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Idle - CPU usage by process exceeds"; Value = "$($RASCPUSettings.IdleUsage) %"; }) > $Null
                    $ScriptInformation.Add(@{Data = "Exclusions"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Processes that will be excluded from CPU Optimization"; Value = ""; }) > $Null
                    
                    If($RASCPUSettings.CPUExcludeList.Count -eq 0)
                    {
                            $ScriptInformation.Add(@{Data = "          Processes to exclude"; Value = "None"; }) > $Null
                    }
                    Else
                    {
                            $cnt = -1
                            
                                Line 3 "Settings for Site $xSiteName"                           ForEach($item in $RASCPUSettings.CPUExcludeList)
                            {
                                    $cnt++
 
                                If($PubItem.PublishFrom -eq "Server") <>                                 If($cnt -eq 0)
 
  <>                                         $ScriptInformation.Add(@{Data = "          Processes to exclude"; Value = $item; }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = ""; Value = $item; }) > $Null
                                    }
                            }
                    }
     
                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASCPUSettings.Replicate.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 275;
                    $Table.Columns.Item(2).Width = 150;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "Enable CPU Optimization`t`t`t`t`t: " $RASCPUSettings.EnableCPUOptimization.ToString()
                    Line 2 "Start"
                    Line 3 "Total CPU usage exceeds`t`t`t`t: " "$($RASCPUSettings.StartUsage) %"
                    Line 2 "CPU Conditions"
                    Line 3 "Critical - CPU usage by process exceeds`t`t: " "$($RASCPUSettings.CriticalUsage) %"
                    Line 3 "Idle - CPU usage by process exceeds`t`t: " "$($RASCPUSettings.IdleUsage) %"
                    Line 2 "Exclusions"
                    Line 3 "Processes that will be excluded from CPU Optimization"
                    
                    If($RASCPUSettings.CPUExcludeList.Count -eq 0)
                    {
                            Line 4 "Processes to exclude`t`t`t: None"
                    }
                    Else
                    {
                                        $cnt = -1                           $cnt = -1
                            
                                        ForEach($Item in $PubItem.PublishFromServer)                           ForEach($item in $RASCPUSettings.CPUExcludeList)
                                        {                           {
                                                $cnt++                                   $cnt++
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server                                  
                                                If($cnt -eq 0)                                   If($cnt -eq 0)
                                                {                                   {
                                                        Line 3 "Published from`t`t`t`t`t`t: " ItemName                                           Line 4 "Processes to exclude`t`t`t: " $item
                                                }                                   }
                                                Else                                   Else
                                                {                                   {
                                                        Line 10 $ItemName                                           Line 9 "  " $item
                                                }                                   }
                                        }                           }
                                }                   }
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                    Line 2 "Settings are replicated to all Sites`t`t`t: " $RASCPUSettings.Replicate.ToString()
                    Line 0 ""
            }
            If($HTML)
                                {           {
                    $rowdata = @()
                    $columnHeaders = @("Enable CPU Optimization",($Script:htmlsb),$RASCPUSettings.EnableCPUOptimization.ToString(),$htmlwhite)
                    $rowdata += @(,("Start",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     Total CPU usage exceeds",($Script:htmlsb),"$($RASCPUSettings.StartUsage) %",$htmlwhite))
                    $rowdata += @(,("CPU Conditions",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     Critical - CPU usage by process exceeds",($Script:htmlsb),"$($RASCPUSettings.CriticalUsage) %",$htmlwhite))
                    $rowdata += @(,("     Idle - CPU usage by process exceeds",($Script:htmlsb),"$($RASCPUSettings.IdleUsage) %",$htmlwhite))
                    $rowdata += @(,("Exclusions",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     Processes that will be excluded from CPU Optimization",($Script:htmlsb),"",$htmlwhite))
                    
                    If($RASCPUSettings.CPUExcludeList.Count -eq 0)
                    {
                            $rowdata += @(,("          Processes to exclude",($Script:htmlsb),"None",$htmlwhite))
                    }
                    Else
                    {
                                        $cnt = -1                           $cnt = -1
                                        ForEach($Item in $PubItem.PublishFromGroup)                          
                            ForEach($item in $RASCPUSettings.CPUExcludeList)
                                        {                           {
                                                $cnt++                                   $cnt++
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name                                  
                                                If($cnt -eq 0)                                   If($cnt -eq 0)
                                                {                                   {
                                                        Line 3 "Published from`t`t`t`t`t`t: " ItemName                                           $rowdata += @(,("          Processes to exclude",($Script:htmlsb),$item,$htmlwhite))
                                                }                                   }
                                                Else                                   Else
                                                {                                   {
                                            $rowdata += @(,("",($Script:htmlsb),$item,$htmlwhite))
                                    }
                            }
                    }
     
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASCPUSettings.Replicate.ToString(),$htmlwhite))
                    $msg = ""
                    $columnWidths = @("300","175")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                    WriteHTMLLine 0 0 ""
            }
    }
    #endregion
     
    #region process publishing
    Function ListFolder($folder, $spaces) 
    {
            #function provided 23-July-2020 by Ian Sant of Parallels
            #list published items in the order they appear in the console
            #modified 24-July-2020 by Webster to make it work with this script
            $prevId = 0
     
            Do
            {
                    $item = $Script:AllItems | Where-Object {($_.ParentId -eq $folder) -and ($_.PreviousId -eq $prevId)}
                                                        Line 10 $ItemName                   If ($Null -eq $item) {
                            Return
                                                }                   }
     
                    #Write-Host $spaces $item.Name
                    $Script:OrderedItems.Add($item) >$Null
                    If ($item.Type -eq "Folder") {
                            $newspaces = $spaces + "   "
                            ListFolder $item.Id $newspaces
                                        }                   }
                    $prevId = $item.Id
            } While ($true) 
                                }   }
     
    Function ProcessPublishing
    {
            Param([object]$Site)
            
            Write-Verbose "$(Get-Date -Format G): Processing Publishing"
            
            OutputPublishingSectionPage $Site.Name
                            
            Write-Verbose "$(Get-Date -Format G): `tProcessing Publishing"
            
            $results = Get-RASPubItem -SiteId $Site.Id -EA 0 4>$Null
                    
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Publishing information for Site $($Site.Name)
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Publishing information for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Publishing information for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Publishing information for Site $($Site.Name)"
                    }
            }
            ElseIf($? -and $null -eq $results)
            {
                    Write-Host "
                    No Publishing information was found for Site $($Site.Name)
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 "No Publishing information was found for Site $($Site.Name)"
                    }
                    If($Text)
                    {
                            Line 0 "No Publishing information was found for Site $($Site.Name)"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 "No Publishing information was found for Site $($Site.Name)"
                    }
            }
                                Else           Else
                                {           {
                    $Script:OrderedItems = New-Object System.Collections.ArrayList
                    $Script:AllItems = $results
                    ListFolder 0 ""
                    OutputPublishingSettings $Script:OrderedItems $Site.Id $Site.Name
            }
    }
     
    Function OutputPublishingSectionPage
    {
            Param([string] $SiteName)
            
            If($MSWord -or $PDF)
            {
                    $Script:Selection.InsertNewPage()
                                        Line 3 "Published from`t`t`t`t`t`t: " "All Servers in Site"                   WriteWordLine 1 0 "Publishing for Site $($SiteName)"
                                }           }
            If($Text)
            {
                                If($PubItem.InheritShortcutDefaultSettings)                   Line 0 "Publishing for Site $($SiteName)"
            }
            If($HTML)
                                {           {
                    WriteHTMLLine 1 0 "Publishing for Site $($SiteName)"
            }
    }
     
    Function OutputPublishingSettings
    {
            Param([object] $PubItems, [uint32] $SiteId, [string] $xSiteName)
            
                                        If($DefaultCreateShortcutOnDesktop -eq "True")           Write-Verbose "$(Get-Date -Format G): `t`tOutput Publishing"
            
            <#
            Folder
            PCApp
            PCDesktop
            RDSApp
            RDSDesktop
            VDIApp
            VDIDesktop
            WVDApp
            WVDDesktop
            #>
     
            #Get the published items default settings
            Write-Verbose "$(Get-Date -Format G): `t`t`tRetrieve Publishing Default Site Settings for Site $xSiteName"
            $results = Get-RASPubDefaultSettings -SiteId $SiteId -EA 0 4>$Null
            
            If(!$?)
                                        {           {
                    Write-Host "
                    Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults
                    " -ForegroundColor White
                    <#
                    StartPath                     : RAS Remote Desktops & Applications\%Groups%
                                                Line 3 "Create shortcut on desktop"                   CreateShortcutOnDesktop       : False
                    CreateShortcutInStartFolder   : True
                    CreateShortcutInStartUpFolder : False
                    ReplicateShortcutSettings     : False
                    ReplicateDisplaySettings      : False
                    WaitForPrinters               : False
                    StartMaximized                : True
                    WaitForPrintersTimeout        : 20
                    ColorDepth                    : ClientSpecified
                    DisableSessionSharing         : False
                    OneInstancePerUser            : False
                    ConCurrentLicenses            : 0
                    LicenseLimitNotify            : WarnUserAndNoStart
                    ReplicateLicenseSettings      : False
                    #>
                    
                    #Shortcuts tab
                    $DefaultCreateShortcutOnDesktop       = "False"
                    $DefaultCreateShortcutInStartFolder   = "True"
                    $DefaultStartPath                     = "RAS Remote Desktops & Applications\%Groups%"
                    $DefaultCreateShortcutInStartUpFolder = "False"
                    $DefaultReplicateShortcutSettings     = "False"
                    
                    #License tab
                    $DefaultDisableSessionSharing         = "False"
                    $DefaultOneInstancePerUser            = "False"
                    $DefaultConCurrentLicenses            = "Unlimited"
                    $DefaultLicenseLimitNotify            = "Warn user and do not start"
                    $DefaultReplicateLicenseSettings      = "False"
     
                    #Display tab
                    $DefaultWaitForPrinters               = "False"
                    $DefaultWaitForPrintersTimeout        = "20"
                    $DefaultColorDepth                    = "Client Specified"
                    $DefaultStartMaximized                = "True"
                    $DefaultReplicateDisplaySettings      = "False"
     
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"
                                        }                   }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Publishing Default Site Settings for Site $xSiteName, using built-in defaults"
                    }
            }
            Else
            {
                    #Shortcuts tab
                    $DefaultCreateShortcutOnDesktop       = $results.CreateShortcutOnDesktop.ToString()      
                                        If($DefaultCreateShortcutInStartFolder -eq "True")                   $DefaultCreateShortcutInStartFolder   = $results.CreateShortcutInStartFolder.ToString()
                    $DefaultStartPath                     = $results.StartPath                    
                    $DefaultCreateShortcutInStartUpFolder = $results.CreateShortcutInStartUpFolder.ToString()
                    $DefaultReplicateShortcutSettings     = $results.ReplicateShortcutSettings.ToString()
     
                    #License tab
                    $DefaultDisableSessionSharing         = $results.DisableSessionSharing.ToString()    
                    $DefaultOneInstancePerUser            = $results.OneInstancePerUser.ToString()
                    If($results.ConCurrentLicenses -eq 0)
                                        {                   {
                            $DefaultConCurrentLicenses        = "Unlimited"
                    }
                    Else
                    {
                            $DefaultConCurrentLicenses        = $results.ConCurrentLicenses.ToString()    
                    }
                     
                    Switch ($results.LicenseLimitNotify)
                    {
                            "WarnUserAndNoStart"            {$DefaultLicenseLimitNotify = "Warn user and do not start"; Break}
                                                Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"                           "WarnUserAndStart"                      {$DefaultLicenseLimitNotify = "Warn user and start"; Break}
                            "NotifyAdminAndStart"           {$DefaultLicenseLimitNotify = "Notify administrator and start"; Break}
                            "NotifyUserAdminAndStart"       {$DefaultLicenseLimitNotify = "Notify user, administrator and start"; Break}
                            "NotifyUserAdminAndNoStart"     {$DefaultLicenseLimitNotify = "Notify user, administrator and do not start"; Break}
                            Default                                         {$DefaultLicenseLimitNotify = "Unable to determine If limit is eceeded: $($results.LicenseLimitNotify)"; Break}
                                        }                   }
                    
                    $DefaultReplicateLicenseSettings      = $results.ReplicateLicenseSettings.ToString()
     
                    #Display tab
                    $DefaultWaitForPrinters               = $results.WaitForPrinters.ToString()
                    $DefaultWaitForPrintersTimeout        = $results.WaitForPrintersTimeout.ToString()
                    Switch ($results.ColorDepth)
                    {
                            "Colors8Bit"            {$DefaultColorDepth = "256 Colors"; Break}
                            "Colors15Bit"           {$DefaultColorDepth = "High Color (15 bit)"; Break}
                            "Colors16Bit"           {$DefaultColorDepth = "High Color (16 bit)"; Break}
                            "Colors24Bit"           {$DefaultColorDepth = "True Color (24 bit)"; Break}
                            "Colors32Bit"           {$DefaultColorDepth = "Highest Quality (32 bit)"; Break}
                            "ClientSpecified"       {$DefaultColorDepth = "Client Specified"; Break}
                            Default                         {$DefaultColorDepth = "Unable to determine Color Depth: $($PubItem.ColorDepth)"; Break}
                    }
                    $DefaultStartMaximized                = $results.StartMaximized.ToString()   
                    $DefaultReplicateDisplaySettings      = $results.ReplicateDisplaySettings.ToString()
            }
            
            ForEach($PubItem in $PubItems)
            {
                    Write-Verbose "$(Get-Date -Format G): `t`t`t`tOutput $($PubItem.Name)"
     
                    If(ValidObject $PubItem WinType)
                    {
                            Switch ($PubItem.WinType)
                            {
                                    "Normal"        {$WinType = "Normal Window"; Break}
                                    "Maximized"     {$WinType = "Maximized"; Break}
                                    "Minimized"     {$WinType = "Minimized"; Break}
                                    Default         {$WinType = "Unable to determine window Run type: $($PubItem.WinType)"; Break}
                            }
                    }
     
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 2 0 $PubItem.Name
                    }
                    If($Text)
                    {
                            Line 1 $PubItem.Name
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 2 0 $PubItem.Name
                    }
            
                    If($PubItem.Type -eq "Folder")
                    {
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Information"
                            }
                            If($Text)
                            {
                                    Line 2 "Information"
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 3 0 "Information"
                            }
                            
                            If($MSWord -or $PDF)
                            {
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Folder"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")                                   $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    
                                    If($PubItem.AdminOnly -eq $True)
                                        {                                   {
                                            $ScriptInformation.Add(@{Data = "Use for administrative purposes"; Value = ""; }) > $Null
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                                Line 3 "Create shortcut in Auto Start Folder"                                    $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
 
  <>                                 If($PubItem.IPFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                Else                                                           Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
 
  <>                                         $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
                                            }
                                            
                                        If($PubItem.CreateShortcutOnDesktop)                                           If($PubItem.AllowedOSes.Chrome)
 
                                                Line 3 "Create shortcut on desktop" <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
  <>                                         
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebClient)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
                                            }
                                    }
     
                                    $cnt =-1
                                        If($PubItem.CreateShortcutInStartFolder)                                   ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
 
  <>                                                 $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
     
                                    If($PubItem.PreferredRoutingEnabled)
                                    {
                                            $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null
                                            
                                            If($? -and $Null -ne $Results)
                                            {
                                                    $cnt =-1
                                                    ForEach($PrefRoute in $Results)
                                                    {
                                                            $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $CustomRoute)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"                                                                           $ScriptInformation.Add(@{Data = "Preferred routing is enabled"; Value = ""; }) > $Null
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"; }) > $Null
                                                                    }
                                                                    Else
                                                                    {
                                                                            $ScriptInformation.Add(@{Data = ""; Value = "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"; }) > $Null
                                                                    }
                                                            }
                                                    }
 
  <>                                 }
                    
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Sites"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    $cnt =-1
                                        If($PubItem.CreateShortcutInStartUpFolder)                                   ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
 
  <>                                                 $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                                Line 3 "Create shortcut in Auto Start Folder"                                   WriteWordLine 3 0 "Folder"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Folder Name"; Value = $PubItem.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Use for administrative purposes"; Value = $PubItem.AdminOnly.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    OutputPubItemFilters $PubItem "MSWordPDF"
                                        }                           }
                            If($Text)
                            {
                                    Line 3 "Folder`t`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
                                    Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                    Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod
                                    Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate
                                    Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()
                                    
                                    If($PubItem.AdminOnly -eq $True)
                                    {
                                            Line 3 "Use for administrative purposes"
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                Line 0 "" +-  
 
                                Line 2 "Sites" <>  
                                Line 3 "This published item will be available from the following Sites"    
                                ForEach($Site in $PubItem.PublishToSite)                                   If($PubItem.PreferredRoutingEnabled)
 
                                        $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name <>                                         $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null
 
                                        Line 10 $SiteName <>                                         If($? -and $Null -ne $Results)
                                }    
                                Line 0 ""    
     
                                Line 2 "Publish from"    
                                Line 3 $PublishedFrom    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        ForEach($Item in $PubItem.PublishFromServer)    
 
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server <>  
                                                Line 6 $ItemName    
                                        }                                                   $cnt =-1
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        ForEach($Item in $PubItem.PublishFromGroup)                                                   ForEach($PrefRoute in $Results)
                                        {                                                   {
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name                                                           $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null
                                                Line 5 $ItemName    
                                        }    
                                }    
                                Line 0 ""    
     
                                Line 2 "Application"    
                                Line 3 "Application"    
                                Line 4 "Name`t`t`t`t`t`t":  $PubItem.Name    
                                Line 4 "Description`t`t`t`t`t: " $PubItem.Description    
                                Line 4 "Run`t`t`t`t`t`t: " $WinType    
                                Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()    
                                Line 0 ""    
                                                                                          
                                Line 3 "Server settings"    
                                Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target    
                                Line 4 "Start in`t`t`t`t`t: " $PubItem.StartIn    
                                Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters    
                                Line 0 ""    
                                    
                                OutputPubItemFilters $PubItem "Text"    
                                    
                                OutputPubItemShortcuts $PubItem "Text" `    
                                $DefaultCreateShortcutOnDesktop `    
                                $DefaultCreateShortcutInStartFolder `    
                                $DefaultStartPath `    
                                $DefaultCreateShortcutInStartUpFolder `    
                                $DefaultReplicateShortcutSettings    
     
                                Line 2 "File extensions"    
                                Line 3 "Associate File Extensions`t`t`t`t: " $PubItem.EnableFileExtensions.ToString()    
     
                                If($PubItem.EnableFileExtensions)                                                           If($? -and $Null -ne $CustomRoute)
                                {                                                           {
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                $cnt++                                                                   $cnt++
                                                If($cnt -eq 0 )                                                                   If($cnt -eq 0)
                                                {                                                                   {
                                                        Line 8 "Extension`t: " $Item                                                                           Line 3 "Preferred routing is enabled"
                                                                            Line 7 "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"
                                                }                                                                   }
                                                Else                                                                   Else
                                                {                                                                   {
                                                        Line 10" $Item                                                                           Line 7 "$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)"
                                                                    }
                                                            }
 
                                Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateFileExtensionSettings.ToString() +-  
 
                                Line 2 "License" <>                                 Line 2 Sites
                                Line 3 "Inherit default settings`t`t`t`t: " $PubItem.InheritLicenseDefaultSettings.ToString()    
                                    $cnt =-1
                                If($PubItem.InheritLicenseDefaultSettings)                                   ForEach($Site in $PubItem.PublishToSite)
 
                                        Line 3 "Session Sharing`t`t`t`t`t`t: " $DefaultDisableSessionSharing <>  
                                        Line 3 "Allow users to start only 1 instance of this application: " $DefaultOneInstancePerUser.ToString()    
                                        Line 3 "Concurrent licenses`t`t`t`t`t: " $DefaultConCurrentLicenses    
                                        Line 3 "If limit is exceeded`t`t`t`t`t: " $DefaultLicenseLimitNotify    
                                }                                           $cnt++
                                Else                                           $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                {    
                                        Line 3 "Session Sharing`t`t`t`t`t`t: " $SessionSharing    
                                        Line 3 "Allow users to start only 1 instance of this application: " $PubItem.OneInstancePerUser.ToString()    
                                        Line 3 "Concurrent licenses`t`t`t`t`t: " $ConCurrentLicenses    
                                        Line 3 "If limit is exceeded`t`t`t`t`t: " $LicenseLimitNotify    
                                }    
                                            
                                If($PubItem.InheritLicenseDefaultSettings)                                           If($cnt -eq 0)
                                {                                           {
                                        Line 3 "Settings are replicated to all Sites`t`t`t: " $DefaultReplicateLicenseSettings.ToString()                                                   Line 3 "This published item will be available from the following Sites: " $SiteName
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateLicenseSettings.ToString()                                                   Line 10 "  " $SiteName
                                }                                           }
                                Line 0 ""    
     
                                Line 2 "Display"    
                                Line 3 "Inherit default settings`t`t`t`t: " $PubItem.InheritDisplayDefaultSettings.ToString()    
     
                                If($PubItem.InheritDisplayDefaultSettings)    
                                {    
                                        Line 3 "Wait until all RAS Universal Printers are redirected "    
                                        Line 3 "before showing the application`t`t`t`t: " $DefaultWaitForPrinters    
                                        Line 3 "Maximum time to wait is`t`t`t`t`t: " "$($DefaultWaitForPrintersTimeout) seconds"    
                                        Line 3 "Color Depth`t`t`t`t`t`t: " $DefaultColorDepth    
                                        Line 3 "Start the application as maximized "    
                                        Line 3 "when using mobile clients`t`t`t`t: " $DefaultStartMaximized    
 
                                Else <>  
                                {                                  
                                        Line 3 "Wait until all RAS Universal Printers are redirected "                                   Line 2 "Folder"
                                        Line 3 "before showing the application`t`t`t`t: " $PubItem.WaitForPrinters.ToString()    
                                        Line 3 "Maximum time to wait is`t`t`t`t`t: " "$($PubItem.WaitForPrintersTimeout.ToString()) seconds"    
                                        Line 3 "Color Depth`t`t`t`t`t`t: " $ColorDepth                                   Line 3 "Folder Name`t`t`t`t`t`t: " $PubItem.Name
                                        Line 3 "Start the application as maximized "    
                                        Line 3 "when using mobile clients`t`t`t`t: " $PubItem.StartMaximized.ToString()                                   Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                }    
     
                                Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateDisplaySettings.ToString()                                   Line 3 "Use for administrative purposest`t`t`t: " $PubItem.AdminOnly.ToString()
 
  -+                                 
                                    OutputPubItemFilters $PubItem "Text"
 
                                WriteHTMLLine 3 0 "Information" +-  
 
                                $columnHeaders = @("Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite) <>                                 $columnHeaders = @("Folder",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
 
                                $rowdata += @(,("Status",($Script:htmlsb),$PubItemMode,$htmlwhite)) +-  
                                $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))    
                                $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))    
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))    
 
                                If(![String]::IsNullOrEmpty($PubItem.Parameters)) <>  
                                {    
                                        $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))    
                                }    
                                    
                                If($PubItem.EnableFileExtensions)    
                                {    
                                        $rowdata += @(,("Associate the following file extensions",($Script:htmlsb),"",$htmlwhite))    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                        }    
                                }    
                                    
                                If($PubItem.InheritLicenseDefaultSettings)    
                                {    
                                        If($DefaultOneInstancePerUser)    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$DefaultConCurrentLicenses,$htmlwhite))    
                                        $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$DefaultLicenseLimitNotify,$htmlwhite))    
                                        $rowdata += @(,("Session Sharing",($Script:htmlsb),$DefaultDisableSessionSharing,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        If($PubItem.OneInstancePerUser)    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$ConCurrentLicenses,$htmlwhite))    
                                        $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$LicenseLimitNotify,$htmlwhite))    
                                        $rowdata += @(,("Session Sharing",($Script:htmlsb),$SessionSharing,$htmlwhite))    
                                }    
     
                                $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))    
                                    
                                If($PubItem.PublishFrom -eq "Server")                                   If($PubItem.AdminOnly -eq $True)
 
                                        $cnt = -1 <>  
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Published from",($Script:htmlsb),"All Servers in Site",$htmlwhite))                                           $rowdata += @(,("Use for administrative purposes",($Script:htmlsb), "",$htmlwhite))
 
                                If($PubItem.InheritShortcutDefaultSettings) +-  
                                {    
                                        If($DefaultCreateShortcutOnDesktop -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))    
                                        }    
                                        If($DefaultCreateShortcutInStartUpFolder -eq "True")    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
                                Else    
                                {    
                                        If($PubItem.CreateShortcutOnDesktop)    
                                        {    
                                                $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))    
                                        }    
                                        If($PubItem.CreateShortcutInStartUpFolder)    
                                        {    
                                                $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))    
                                        }    
                                }    
     
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
  <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
                                    }
     
                                    If($PubItem.PreferredRoutingEnabled)
                                    {
                                            $Results = Get-RASPubItemPreferredRoute -Id $PubItem.Id -EA 0 4> $Null
                                            
                                            If($? -and $Null -ne $Results)
                                            {
                                                    $cnt =-1
                                                    ForEach($PrefRoute in $Results)
                                                    {
                                                            $CustomRoute = Get-RASCustomRoute -Id $PrefRoute.Id -EA 0 4>$Null
                                                            
                                                            If($? -and $Null -ne $CustomRoute)
                                                            {
                                                                    $cnt++
                                                                    If($cnt -eq 0)
                                                                    {
                                                                            $rowdata += @(,("Preferred routing is enabled",($Script:htmlsb),"",$htmlwhite))
                                                                            $rowdata += @(,("",($Script:htmlsb),"$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)",$htmlwhite))
                                                                    }
                                                                    Else
                                                                    {
                                                                            $rowdata += @(,("",($Script:htmlsb),"$($CustomRoute.Name), custom route on IP $($CustomRoute.PublicAddress)",$htmlwhite))
                                                                    }
                                                            }
                                                    }
                                            }
                                    }
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Folder"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Folder",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Use for administrative purposes",($Script:htmlsb),$PubItem.AdminOnly.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    OutputPubItemFilters $PubItem "HTML"
                            }
                    }
                    ElseIf($PubItem.Type -eq "PCApp")
                    {
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Information"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Remote PC Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
     
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                    {
                                            $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
                                    }
                                    
                                    $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null
                                    
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
                                            }
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Sites"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Remote PC Application"
                                    WriteWordLine 4 0 "Application"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                                    
                                    OutputPubItemFilters $PubItem "MSWordPDF"
                                    
                                    OutputPubItemShortcuts $PubItem "MSWordPDF" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                            }
                            If($Text)
                            {
                                    Line 2 "Information"
                                    Line 3 "Remote PC Application`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
                                    Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                    Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod
                                    Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate
                                    Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()
                                    Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target
                                    Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn
                                    Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()
                                    
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                    {
                                            Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters
                                    }
                                    
                                    Line 3 "Settings for Site $xSiteName"
     
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    Line 3 "Create shortcut on desktop"
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    Line 3 "Create shortcut on desktop"
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            Line 3 "Own Filters"
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            Line 3 " User filtering is enabled"
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    Line 10 "  " $Item.Account
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            Line 3 " IP filtering is enabled"
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
                                                            }
                                                            Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
                                                            }
                                                            Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                                            }
                                                    }
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            Line 3 " Client filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            Line 3 " MAC filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            Line 3 " Gateway filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            Line 3 " Client device operating system filtering is enabled"
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    Line 10 "  Android"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    Line 10 "  Chrome OS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    Line 10 "  iOS/iPadOS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    Line 10 "  Linux"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    Line 10 "  macOS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    Line 10 "  RAS Web Portal"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    Line 10 "  Windows"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    Line 10 "  Wyse"
                                            }
                                            Line 0 ""
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName
                                            }
                                            Else
                                            {
                                                    Line 10 $SiteName
                                            }
                                    }
                                    Line 0 ""
     
                                    Line 2 "Sites"
                                    Line 3 "This published item will be available from the following Sites"
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            Line 10 $SiteName
                                    }
                                    Line 0 ""
     
                                    Line 2 "Remote PC Application"
                                    Line 3 "Application"
                                    Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name
                                    Line 4 "Description`t`t`t`t`t: " $PubItem.Description
                                    Line 4 "Run`t`t`t`t`t`t: " $WinType
                                    Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target
                                    Line 4 "Start In`t`t`t`t`t: " $PubItem.StartIn
                                    Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters
                                    Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()
                                    Line 0 ""
                                    
                                    OutputPubItemFilters $PubItem "Text"
                                    
                                    OutputPubItemShortcuts $PubItem "Text" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 3 0 "Information"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Remote PC Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                    $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
                                    
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                    {
                                            $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
                                    }
                                    
                                    $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))
                                    
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
                                WriteHTMLLine 3 0 "Publish from" <>  
                                $rowdata = @()    
                                If($PubItem.PublishFrom -eq "Server")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromServer)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                ElseIf($PubItem.PublishFrom -eq "Group")    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.PublishFromGroup)    
                                        {    
                                                $cnt++    
                                                $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                Else    
                                {    
                                        $columnHeaders = @("$PublishedFrom",($Script:htmlsb),"",$htmlwhite)    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Application"                                   WriteHTMLLine 3 0 "Remote PC Application"
 
                                $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite)) +-  
     
                                $msg = "Application"    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
                                    
                                $rowdata = @()    
                                $columnHeaders = @("Server(s)",($Script:htmlsb),"",$htmlwhite)    
 
                                $rowdata += @(,("Start in",($Script:htmlsb),$PubItem.StartIn,$htmlwhite)) <>                                 $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
 
  -+                                 $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
 
                                $msg = "Server settings" <>                                 $msg = "Application"
 
  <>                                 
 
  +-  
                                WriteHTMLLine 3 0 "File extensions"    
                                $rowdata = @()    
                                $columnHeaders = @("Associate File Extensions",($Script:htmlsb),$PubItem.EnableFileExtensions.ToString(),$htmlwhite)    
                                    
                                If($PubItem.EnableFileExtensions)    
                                {    
                                        $cnt = -1    
                                        ForEach($Item in $PubItem.FileExtensions)    
                                        {    
                                                $cnt++    
                                                    
                                                If($cnt -eq 0)    
                                                {    
                                                        $rowdata += @(,("Extension",($Script:htmlsb),$Item,$htmlwhite))    
                                                }    
                                                Else    
                                                {    
                                                        $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))    
                                                }    
                                        }    
                                }    
                                $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateFileExtensionSettings.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
     
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "License"    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$PubItem.InheritLicenseDefaultSettings.ToString(),$htmlwhite)    
     
                                If($PubItem.InheritLicenseDefaultSettings)    
                                {    
                                        $rowdata += @(,("Session Sharing",($Script:htmlsb),$DefaultDisableSessionSharing,$htmlwhite))    
                                        If($DefaultOneInstancePerUser)    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$DefaultConCurrentLicenses,$htmlwhite))    
                                        $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$DefaultLicenseLimitNotify,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Session Sharing",($Script:htmlsb),$SessionSharing,$htmlwhite))    
                                        If($PubItem.OneInstancePerUser)    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))    
                                        }    
                                        Else    
                                        {    
                                                $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))    
                                        }    
                                        $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$ConCurrentLicenses,$htmlwhite))    
                                        $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$LicenseLimitNotify,$htmlwhite))    
                                }    
                                If($PubItem.InheritLicenseDefaultSettings)    
                                {    
                                        $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$DefaultReplicateLicenseSettings.ToString(),$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateLicenseSettings.ToString(),$htmlwhite))    
                                }    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                                WriteHTMLLine 0 0 ""    
     
                                WriteHTMLLine 3 0 "Display"    
                                $rowdata = @()    
                                $columnHeaders = @("Inherit default settings",($Script:htmlsb),$PubItem.InheritDisplayDefaultSettings.ToString(),$htmlwhite)    
     
                                If($PubItem.InheritDisplayDefaultSettings)    
                                {    
                                        $rowdata += @(,("Wait until all RAS Universal Printers are redirected before showing the application",($Script:htmlsb),$DefaultWaitForPrinters,$htmlwhite))    
                                        $rowdata += @(,("Maximum time to wait is",($Script:htmlsb),"$($DefaultWaitForPrintersTimeout) seconds",$htmlwhite))    
                                        $rowdata += @(,("Color Depth",($Script:htmlsb),$DefaultColorDepth,$htmlwhite))    
                                        $rowdata += @(,("Start the application as maximized when using mobile clients",($Script:htmlsb),$DefaultStartMaximized,$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,("Wait until all RAS Universal Printers are redirected before showing the application",($Script:htmlsb),$PubItem.WaitForPrinters.ToString(),$htmlwhite))    
                                        $rowdata += @(,("Maximum time to wait is",($Script:htmlsb),"$($PubItem.WaitForPrintersTimeout.ToString()) seconds",$htmlwhite))    
                                        $rowdata += @(,("Color Depth",($Script:htmlsb),$ColorDepth,$htmlwhite))    
                                        $rowdata += @(,("Start the application as maximized when using mobile clients",($Script:htmlsb),$PubItem.StartMaximized.ToString(),$htmlwhite))    
                                }    
                                $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateDisplaySettings.ToString(),$htmlwhite))    
     
                                $msg = ""    
                                $columnWidths = @("200","300")    
                                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
     
                                WriteHTMLLine 0 0 ""    
 
                ElseIf($PubItem.Type -eq "RDSDesktop") <>                 ElseIf($PubItem.Type -eq "PCDesktop")
 
                        Switch ($PubItem.PublishFrom) +-  
                        {    
                                "All"           {$PublishedFrom = "All Servers in Site"; Break}    
                                "Group"         {$PublishedFrom = "Groups:"; Break}    
                                "Server"        {$PublishedFrom = "Individual Servers:"; Break}    
                                Default         {$PublishedFrom = "Unable to determine Published From: $($PubItem.PublishFrom)"; Break}    
                        }    
                            
 
  <>                         
 
  -+                                 
 
                                $ScriptInformation.Add(@{Data = "RD Session Host Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Remote PC Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
 
  <>                                 $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
                                            }
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Sites"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Remote PC Desktop"
                                    WriteWordLine 4 0 "Remote PC Desktop"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                $ScriptInformation.Add(@{Data = "Connect to administrative session"; Value = $PubItem.ConnectToConsole.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 4 0 "Properties"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    #$ScriptInformation.Add(@{Data = "Select Remote PC"; Value = ""; }) > $Null
 
  -+                                 $ScriptInformation.Add(@{Data = "Multi-Monitor"; Value = $AllowMultiMonitor; }) > $Null
                                    
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    OutputPubItemFilters $PubItem "MSWordPDF"
     
                                    OutputPubItemShortcuts $PubItem "MSWordPDF" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                            }
                            If($Text)
                            {
                                    Line 2 "Information"
                                    Line 3 "Remote PC Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
                                    Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                    Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod
                                    Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate
                                    Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()
                                    Line 3 "Desktop Size`t`t`t`t`t`t: " $DesktopSize
     
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    Line 3 "Create shortcut on desktop"
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    Line 3 "Create shortcut on desktop"
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            Line 3 "Own Filters"
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            Line 3 " User filtering is enabled"
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    Line 10 "  " $Item.Account
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            Line 3 " IP filtering is enabled"
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
                                                            }
                                                            Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
                                                            }
                                                            Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                                            }
                                                    }
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            Line 3 " Client filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            Line 3 " MAC filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            Line 3 " Gateway filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            Line 3 " Client device operating system filtering is enabled"
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    Line 10 "  Android"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    Line 10 "  Chrome OS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    Line 10 "  iOS/iPadOS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    Line 10 "  Linux"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    Line 10 "  macOS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    Line 10 "  RAS Web Portal"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    Line 10 "  Windows"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    Line 10 "  Wyse"
                                            }
                                            Line 0 ""
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Available in Site(s):`t`t`t`t`t" $SiteName
                                            }
                                            Else
                                            {
                                                    Line 10 $SiteName
                                            }
                                    }
                                    Line 0 ""
     
                                    Line 2 "Sites"
                                    Line 3 "This published item will be available from the following Sites"
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            Line 10 $SiteName
                                    }
                                    Line 0 ""
     
                                    Line 2 "Remote PC Desktop"
                                    Line 3 "Remote PC Desktop"
                                    Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name
                                    Line 4 "Description`t`t`t`t`t: " $PubItem.Description
                                    Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()
                                    Line 0 ""
                                    Line 3 "Properties"
                                    Line 4 "Desktop Size`t`t`t`t`t: " $DesktopSize
                                    Line 4 "Multi-Monitor`t`t`t`t`t: " $AllowMultiMonitor
                                    Line 0 ""
     
                                    OutputPubItemFilters $PubItem "Text"
                                    
                                    OutputPubItemShortcuts $PubItem "Text" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 3 0 "Information"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Remote PC Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
                                    }
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Sites"
                                    $rowdata = @()
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
                                    }
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Remote PC Desktop"
                                    $rowdata = @()
                                    $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 4 0 "Properties"
                                    $rowdata = @()
                                    $columnHeaders = @("Select Remote PC",($Script:htmlsb),"",$htmlwhite)
                                    $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))
                                    $rowdata += @(,("Multi-Monitor",($Script:htmlsb),$AllowMultiMonitor,$htmlwhite))
                                    
                                    $msg = "Remote PC Desktop"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    OutputPubItemFilters $PubItem "HTML"
     
                                    OutputPubItemShortcuts $PubItem "HTML" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                            }
                    }
                    ElseIf($PubItem.Type -eq "RDSApp")
                    {
                            Switch ($PubItem.ConCurrentLicenses)
                            {
                                    0               {$ConCurrentLicenses = "Unlimited"; Break}
                                    Default {$ConCurrentLicenses = $PubItem.ConCurrentLicenses.ToString(); Break} 
                            }
                            
                            Switch ($PubItem.DisableSessionSharing)
                            {
                                    $False  {$SessionSharing = "Enabled"; Break}
                                    $True   {$SessionSharing = "Disabled"; Break}
                                    Default {$SessionSharing = "Unable to determine Session Sharing state: $($PubItem.DisableSessionSharing)"; Break}
                            }
                            
                            Switch ($PubItem.PublishFrom)
                            {
                                    "All"           {$PublishedFrom = "All Servers in Site"; Break}
                                    "Group"         {$PublishedFrom = "Server Groups:"; Break}
                                    "Server"        {$PublishedFrom = "Individual Servers:"; Break}
                                    Default         {$PublishedFrom = "Unable to determine Published From: $($PubItem.PublishFrom)"; Break}
                            }
                            
                            Switch ($PubItem.LicenseLimitNotify)
                            {
                                    "WarnUserAndNoStart"            {$LicenseLimitNotify ="Warn user and do not start"; Break}
                                    "WarnUserAndStart"                      {$LicenseLimitNotify ="Warn user and start"; Break}
                                    "NotifyAdminAndStart"           {$LicenseLimitNotify ="Notify administrator and start"; Break}
                                    "NotifyUserAdminAndStart"       {$LicenseLimitNotify ="Notify user, administrator and start"; Break}
                                    "NotifyUserAdminAndNoStart"     {$LicenseLimitNotify ="Notify user, administrator and do not start"; Break}
                                    Default {$LicenseLimitNotify ="Unable to determine If limit is exceeded: $($PubItem.LicenseLimitNotify)"; Break}
                            }
                            
                            Switch ($PubItem.ColorDepth)
                            {
                                    "Colors8Bit"            {$ColorDepth = "256 Colors"; Break}
                                    "Colors15Bit"           {$ColorDepth = "High Color (15 bit)"; Break}
                                    "Colors16Bit"           {$ColorDepth = "High Color (16 bit)"; Break}
                                    "Colors24Bit"           {$ColorDepth = "True Color (24 bit)"; Break}
                                    "Colors32Bit"           {$ColorDepth = "Highest Quality (32 bit)"; Break}
                                    "ClientSpecified"       {$ColorDepth = "Client Specified"; Break}
                                    Default                         {$ColorDepth = "Unable to determine Color Depth: $($PubItem.ColorDepth)"; Break}
                            }
                            
                            Switch($PubItem.EnabledMode)
                            {
                                    "Disabled"              {$PubItemMode = "Disabled"; Break}
                                    "Enabled"               {$PubItemMode = "Enabled"; Break}
                                    "Maintenance"   {$PubItemMode = "In maintenance"; Break}
                                    Default                 {$PubItemMode = "Unable to determine Enabled Mode: $($PubItem.EnabledMode)"; Break}
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Information"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Application"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Status"; Value = $PubItemMode; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start In"; Value = $PubItem.StartIn; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
     
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                    {
                                            $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
                                    }
                                    
                                    If($PubItem.EnableFileExtensions)
                                    {
                                            $ScriptInformation.Add(@{Data = "Associate the following file extensions"; Value = ""; }) > $Null
                                            ForEach($Item in $PubItem.FileExtensions)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            If($DefaultOneInstancePerUser)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $DefaultConCurrentLicenses; }) > $Null
                                            $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $DefaultLicenseLimitNotify; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $DefaultDisableSessionSharing ; }) > $Null
                                    }
                                    Else
                                    {
                                            If($PubItem.OneInstancePerUser)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $ConCurrentLicenses; }) > $Null
                                            $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $LicenseLimitNotify; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $SessionSharing; }) > $Null
                                    }
     
                                    $ScriptInformation.Add(@{Data = "Settings for Site $xSiteName"; Value = ""; }) > $Null
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
 
                                WriteWordLine 3 0 "Desktop" <>                                 WriteWordLine 3 0 "Application"
                                WriteWordLine 4 0 "Desktop"                                   WriteWordLine 4 0 "Application"
 
                                $ScriptInformation.Add(@{Data = "Connect to administrative session"; Value = $PubItem.ConnectToConsole.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Run"; Value = $WinType; }) > $Null
 
                                WriteWordLine 4 0 "Properties" <>                                 WriteWordLine 4 0 "Server settings"
 
                                $ScriptInformation.Add(@{Data = "Desktop size"; Value = $DesktopSize; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Target"; Value = $PubItem.Target; }) > $Null
                                $ScriptInformation.Add(@{Data = "Multi-Monitor"; Value = $AllowMultiMonitor; }) > $Null                                   $ScriptInformation.Add(@{Data = "Start in"; Value = $PubItem.StartIn; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Parameters"; Value = $PubItem.Parameters; }) > $Null
 
  -+  
                                    WriteWordLine 3 0 "File extensions"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Associate File Extensions"; Value = $PubItem.EnableFileExtensions.ToString(); }) > $Null
     
                                    If($PubItem.EnableFileExtensions)
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.FileExtensions)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Extension"; Value = $Item; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                                    }
                                            }
                                    }
                                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateFileExtensionSettings.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "License"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $PubItem.InheritLicenseDefaultSettings.ToString(); }) > $Null
     
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $DefaultDisableSessionSharing ; }) > $Null
                                            If($DefaultOneInstancePerUser)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $DefaultConCurrentLicenses; }) > $Null
                                            $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $DefaultLicenseLimitNotify; }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "Session Sharing"; Value = $SessionSharing; }) > $Null
                                            If($PubItem.OneInstancePerUser)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "True"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "Allow users to start only 1 instance of this application"; Value = "False"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "Concurrent licenses"; Value = $ConCurrentLicenses; }) > $Null
                                            $ScriptInformation.Add(@{Data = "If limit is exceeded"; Value = $LicenseLimitNotify; }) > $Null
                                    }
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateLicenseSettings.ToString(); }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateLicenseSettings.ToString(); }) > $Null
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Display"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Inherit default settings"; Value = $PubItem.InheritDisplayDefaultSettings.ToString(); }) > $Null
     
                                    If($PubItem.InheritDisplayDefaultSettings)
                                    {
                                            $ScriptInformation.Add(@{Data = "Wait until all RAS Universal Printers are redirected before showing the application"; Value = $DefaultWaitForPrinters; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Maximum time to wait is"; Value = "$($DefaultWaitForPrintersTimeout) seconds"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Color Depth"; Value = $DefaultColorDepth; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Start the application as maximized when using mobile clients"; Value = $DefaultStartMaximized; }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "Wait until all RAS Universal Printers are redirected before showing the application"; Value = $PubItem.WaitForPrinters.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "Maximum time to wait is"; Value = "$($PubItem.WaitForPrintersTimeout.ToString()) seconds"; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Color Depth"; Value = $ColorDepth; }) > $Null
                                            $ScriptInformation.Add(@{Data = "Start the application as maximized when using mobile clients"; Value = $PubItem.StartMaximized.ToString(); }) > $Null
                                    }
                                    If($PubItem.InheritDisplayDefaultSettings)
                                    {
                                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $DefaultReplicateDisplaySettings.ToString(); }) > $Null
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.ReplicateDisplaySettings.ToString(); }) > $Null
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
     
                                    WriteWordLine 0 0 ""
 
                                Line 3 "RD Session Host Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)" <>                                 Line 3 "Application`t`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
 
  <>                                 Line 3 "Status`t`t`t`t`t`t`t: " $PubItemMode
                                    Line 3 "Target`t`t`t`t`t`t`t: " $PubItem.Target
                                    Line 3 "Start In`t`t`t`t`t`t: " $PubItem.StartIn
                                    Line 3 "Start automatically when user logs on`t`t`t: " $PubItem.StartOnLogon.ToString()
                                    
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                    {
                                            Line 3 "Parameters`t`t`t`t`t`t: " $PubItem.Parameters
                                    }
                                    
                                    If($PubItem.EnableFileExtensions)
                                    {
                                            Line 3 "Associate the following file extensions"
                                            ForEach($Item in $PubItem.FileExtensions)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                    }
                                    
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            Line 3 "Allow users to start only 1 instance of this application: " $DefaultOneInstancePerUser.ToString()
                                            Line 3 "Concurrent licenses`t`t`t`t`t: " $DefaultConCurrentLicenses
                                            Line 3 "If limit is exceeded`t`t`t`t`t: " $DefaultLicenseLimitNotify
                                            Line 3 "Session Sharing`t`t`t`t`t`t: " $DefaultDisableSessionSharing 
                                    }
                                    Else
                                    {
                                Line 3 "Connect to administrative session`t`t`t: " $PubItem.ConnectToConsole.ToString()                                           Line 3 "Allow users to start only 1 instance of this application: " $PubItem.OneInstancePerUser.ToString()
                                            Line 3 "Concurrent licenses`t`t`t`t`t: " $ConCurrentLicenses
                                            Line 3 "If limit is exceeded`t`t`t`t`t: " $LicenseLimitNotify
                                Line 3 "Desktop Size`t`t`t`t`t`t: " $DesktopSize                                           Line 3 "Session Sharing`t`t`t`t`t`t: " $SessionSharing
                                    }
     
                                    Line 3 "Settings for Site $xSiteName"
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                 <>  
                                Line 2 "Desktop"                                   Line 2 "Application"
                                Line 3 "Desktop"                                   Line 3 "Application"
                                Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name                                   Line 4 "Name`t`t`t`t`t`t":  $PubItem.Name
 
                                Line 4 "Connect to administrative session`t`t: " $PubItem.ConnectToConsole.ToString() <>                                 Line 4 "Run`t`t`t`t`t`t: " $WinType
 
                                Line 3 "Properties" <>                                 Line 3 "Server settings"
                                Line 4 "Desktop size`t`t`t`t`t: " $DesktopSize                                   Line 4 "Target`t`t`t`t`t`t: " $PubItem.Target
                                Line 4 "Multi-Monitor`t`t`t`t`t: " $AllowMultiMonitor                                   Line 4 "Start in`t`t`t`t`t: " $PubItem.StartIn
                                    Line 4 "Parameters`t`t`t`t`t: " $PubItem.Parameters
 
  <>                                 
 
  -+  
                                    Line 2 "File extensions"
                                    Line 3 "Associate File Extensions`t`t`t`t: " $PubItem.EnableFileExtensions.ToString()
     
                                    If($PubItem.EnableFileExtensions)
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.FileExtensions)
                                            {
                                                    $cnt++
                                                    If($cnt -eq 0 )
                                                    {
                                                            Line 8 "Extension`t: " $Item
                                                    }
                                                    Else
                                                    {
                                                            Line 10 "  " $Item
                                                    }
                                            }
                                    }
                                    Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateFileExtensionSettings.ToString()
                                    Line 0 ""
     
                                    Line 2 "License"
                                    Line 3 "Inherit default settings`t`t`t`t: " $PubItem.InheritLicenseDefaultSettings.ToString()
     
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            Line 3 "Session Sharing`t`t`t`t`t`t: " $DefaultDisableSessionSharing
                                            Line 3 "Allow users to start only 1 instance of this application: " $DefaultOneInstancePerUser.ToString()
                                            Line 3 "Concurrent licenses`t`t`t`t`t: " $DefaultConCurrentLicenses
                                            Line 3 "If limit is exceeded`t`t`t`t`t: " $DefaultLicenseLimitNotify
                                    }
                                    Else
                                    {
                                            Line 3 "Session Sharing`t`t`t`t`t`t: " $SessionSharing
                                            Line 3 "Allow users to start only 1 instance of this application: " $PubItem.OneInstancePerUser.ToString()
                                            Line 3 "Concurrent licenses`t`t`t`t`t: " $ConCurrentLicenses
                                            Line 3 "If limit is exceeded`t`t`t`t`t: " $LicenseLimitNotify
                                    }
     
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            Line 3 "Settings are replicated to all Sites`t`t`t: " $DefaultReplicateLicenseSettings.ToString()
                                    }
                                    Else
                                    {
                                            Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateLicenseSettings.ToString()
                                    }
                                    Line 0 ""
     
                                    Line 2 "Display"
                                    Line 3 "Inherit default settings`t`t`t`t: " $PubItem.InheritDisplayDefaultSettings.ToString()
     
                                    If($PubItem.InheritDisplayDefaultSettings)
                                    {
                                            Line 3 "Wait until all RAS Universal Printers are redirected "
                                            Line 3 "before showing the application`t`t`t`t: " $DefaultWaitForPrinters
                                            Line 3 "Maximum time to wait is`t`t`t`t`t: " "$($DefaultWaitForPrintersTimeout) seconds"
                                            Line 3 "Color Depth`t`t`t`t`t`t: " $DefaultColorDepth
                                            Line 3 "Start the application as maximized "
                                            Line 3 "when using mobile clients`t`t`t`t: " $DefaultStartMaximized
                                    }
                                    Else
                                    {
                                            Line 3 "Wait until all RAS Universal Printers are redirected "
                                            Line 3 "before showing the application`t`t`t`t: " $PubItem.WaitForPrinters.ToString()
                                            Line 3 "Maximum time to wait is`t`t`t`t`t: " "$($PubItem.WaitForPrintersTimeout.ToString()) seconds"
                                            Line 3 "Color Depth`t`t`t`t`t`t: " $ColorDepth
                                            Line 3 "Start the application as maximized "
                                            Line 3 "when using mobile clients`t`t`t`t: " $PubItem.StartMaximized.ToString()
                                    }
     
                                    Line 3 "Settings are replicated to all Sites`t`t`t: " $PubItem.ReplicateDisplaySettings.ToString()
                                    Line 0 ""
 
  <>  
                                $columnHeaders = @("RD Session Host Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)                                   $columnHeaders = @("Application",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
 
  <>                                 $rowdata += @(,("Status",($Script:htmlsb),$PubItemMode,$htmlwhite))
                                    $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                    $rowdata += @(,("Start In",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                                $rowdata += @(,("Connect to administrative session",($Script:htmlsb),$PubItem.ConnectToConsole.ToString(),$htmlwhite))                                   $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
                                    
                                    If(![String]::IsNullOrEmpty($PubItem.Parameters))
                                    {
                                            $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
                                    }
                                    
                                    If($PubItem.EnableFileExtensions)
                                    {
                                            $rowdata += @(,("Associate the following file extensions",($Script:htmlsb),"",$htmlwhite))
                                            ForEach($Item in $PubItem.FileExtensions)
                                            {
                                $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))                                                   $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            If($DefaultOneInstancePerUser)
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                                            }
                                            $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$DefaultConCurrentLicenses,$htmlwhite))
                                            $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$DefaultLicenseLimitNotify,$htmlwhite))
                                            $rowdata += @(,("Session Sharing",($Script:htmlsb),$DefaultDisableSessionSharing,$htmlwhite))
                                    }
                                    Else
                                    {
                                            If($PubItem.OneInstancePerUser)
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                                            }
                                            $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$ConCurrentLicenses,$htmlwhite))
                                            $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$LicenseLimitNotify,$htmlwhite))
                                            $rowdata += @(,("Session Sharing",($Script:htmlsb),$SessionSharing,$htmlwhite))
                                    }
     
                                    $rowdata += @(,("Settings for Site $xSiteName",($Script:htmlsb),"",$htmlwhite))
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
  -+                                 WriteHTMLLine 3 0 "Application"
                                    $rowdata = @()
     
                                    $columnHeaders = @("Name",($Script:htmlsb),$PubItem.Name,$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Run",($Script:htmlsb),$WinType,$htmlwhite))
                                    $rowdata += @(,("Start automatically when user logs on",($Script:htmlsb),$PubItem.StartOnLogon.ToString(),$htmlwhite))
     
                                    $msg = "Application"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
                                    
                                    $rowdata = @()
                                    $columnHeaders = @("Server(s)",($Script:htmlsb),"",$htmlwhite)
                                    $rowdata += @(,("Target",($Script:htmlsb),$PubItem.Target,$htmlwhite))
                                    $rowdata += @(,("Start in",($Script:htmlsb),$PubItem.StartIn,$htmlwhite))
                                    $rowdata += @(,("Parameters",($Script:htmlsb),$PubItem.Parameters,$htmlwhite))
     
                                    $msg = "Server settings"
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    OutputPubItemFilters $PubItem "HTML"
                                    
                                    OutputPubItemShortcuts $PubItem "HTML" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
     
                                    WriteHTMLLine 3 0 "File extensions"
                                    $rowdata = @()
                                    $columnHeaders = @("Associate File Extensions",($Script:htmlsb),$PubItem.EnableFileExtensions.ToString(),$htmlwhite)
                                    
                                    If($PubItem.EnableFileExtensions)
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.FileExtensions)
                                            {
                                                    $cnt++
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $rowdata += @(,("Extension",($Script:htmlsb),$Item,$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                                    }
                                            }
                                    }
                                    $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateFileExtensionSettings.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "License"
                                    $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$PubItem.InheritLicenseDefaultSettings.ToString(),$htmlwhite)
     
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            $rowdata += @(,("Session Sharing",($Script:htmlsb),$DefaultDisableSessionSharing,$htmlwhite))
                                            If($DefaultOneInstancePerUser)
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                                            }
                                            $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$DefaultConCurrentLicenses,$htmlwhite))
                                            $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$DefaultLicenseLimitNotify,$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Session Sharing",($Script:htmlsb),$SessionSharing,$htmlwhite))
                                            If($PubItem.OneInstancePerUser)
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"True",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("Allow users to start only 1 instance of this application",($Script:htmlsb),"False",$htmlwhite))
                                            }
                                            $rowdata += @(,("Concurrent licenses",($Script:htmlsb),$ConCurrentLicenses,$htmlwhite))
                                            $rowdata += @(,("If limit is exceeded",($Script:htmlsb),$LicenseLimitNotify,$htmlwhite))
                                    }
                                    If($PubItem.InheritLicenseDefaultSettings)
                                    {
                                            $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$DefaultReplicateLicenseSettings.ToString(),$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateLicenseSettings.ToString(),$htmlwhite))
                                    }
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Display"
                                    $rowdata = @()
                                    $columnHeaders = @("Inherit default settings",($Script:htmlsb),$PubItem.InheritDisplayDefaultSettings.ToString(),$htmlwhite)
     
                                    If($PubItem.InheritDisplayDefaultSettings)
                                    {
                                            $rowdata += @(,("Wait until all RAS Universal Printers are redirected before showing the application",($Script:htmlsb),$DefaultWaitForPrinters,$htmlwhite))
                                            $rowdata += @(,("Maximum time to wait is",($Script:htmlsb),"$($DefaultWaitForPrintersTimeout) seconds",$htmlwhite))
                                            $rowdata += @(,("Color Depth",($Script:htmlsb),$DefaultColorDepth,$htmlwhite))
                                            $rowdata += @(,("Start the application as maximized when using mobile clients",($Script:htmlsb),$DefaultStartMaximized,$htmlwhite))
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Wait until all RAS Universal Printers are redirected before showing the application",($Script:htmlsb),$PubItem.WaitForPrinters.ToString(),$htmlwhite))
                                            $rowdata += @(,("Maximum time to wait is",($Script:htmlsb),"$($PubItem.WaitForPrintersTimeout.ToString()) seconds",$htmlwhite))
                                            $rowdata += @(,("Color Depth",($Script:htmlsb),$ColorDepth,$htmlwhite))
                                            $rowdata += @(,("Start the application as maximized when using mobile clients",($Script:htmlsb),$PubItem.StartMaximized.ToString(),$htmlwhite))
                                    }
                                    $rowdata += @(,("Settings are replicated to all Sites: ",($Script:htmlsb),$PubItem.ReplicateDisplaySettings.ToString(),$htmlwhite))
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                                    WriteHTMLLine 0 0 ""
                            }
                    }
                    ElseIf($PubItem.Type -eq "RDSDesktop")
                    {
                            $DesktopSize = "Unable to determine"
                            If($PubItem.DesktopSize -eq "FullScreen")
                            {
                                    $DesktopSize = "Full Screen"
                            }
                            ElseIf($PubItem.DesktopSize -eq "UseAvailableArea")
                            {
                                    $DesktopSize = "Use available area"
                            }
                            Else
                            {
                                    $DesktopSize = "$($PubItem.Width.ToString())x$($PubItem.Height.ToString())"
                            }
                            
                            Switch ($PubItem.PublishFrom)
                            {
                                    "All"           {$PublishedFrom = "All Servers in Site"; Break}
                                    "Group"         {$PublishedFrom = "Groups:"; Break}
                                    "Server"        {$PublishedFrom = "Individual Servers:"; Break}
                                    Default         {$PublishedFrom = "Unable to determine Published From: $($PubItem.PublishFrom)"; Break}
                            }
                            
                            If($PubItem.AllowMultiMonitor -eq "UseClientSettings")
                            {
                                    $AllowMultiMonitor = "Use Client Settings"
                            }
                            Else
                            {
                                    $AllowMultiMonitor = $PubItem.AllowMultiMonitor.ToString()
                            }
     
                            If($MSWord -or $PDF)
                            {
                                    WriteWordLine 3 0 "Information"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "RD Session Host Desktop"; Value = "#$($PubItem.Id): $($PubItem.Name)"; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Last modification by"; Value = $PubItem.AdminLastMod; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Modified on"; Value = $PubItem.TimeLastMod.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created by"; Value = $PubItem.AdminCreate; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Created on"; Value = $PubItem.TimeCreate.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Connect to administrative session"; Value = $PubItem.ConnectToConsole.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Desktop Size"; Value = $DesktopSize; }) > $Null
                                    
                                    If($PubItem.PublishFrom -eq "Server")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                                                    }
                                            }
                                    }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromGroup)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    If($cnt -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "Published from"; Value = $ItemName; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                                                    }
                                            }
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "Published from"; Value = "All Servers in Site"; }) > $Null
                                    }
     
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($DefaultStartPath)'"; }) > $Null
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut on desktop"; Value = ""; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Start Menu under "; Value = "'$($PubItem.StartPath)'"; }) > $Null
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Create shortcut in Auto Start Folder"; Value = ""; }) > $Null
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = "Own Filters"; Value = ""; }) > $Null
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " User filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item.Account; }) > $Null
                                            }
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " IP filtering is enabled"; Value = ""; }) > $Null
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = $item.From; }) > $Null
                                                            }
                                                            Else
                                                            {
                                                                    $ScriptInformation.Add(@{Data = ""; Value = "$($item.From) - $($item.To)"; }) > $Null
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " MAC filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Gateway filtering is enabled"; Value = ""; }) > $Null
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $Item; }) > $Null
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $ScriptInformation.Add(@{Data = " Client device operating system filtering is enabled"; Value = ""; }) > $Null
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Android"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Linux"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "macOS"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Windows"; }) > $Null
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Wyse"; }) > $Null
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "Available in Site(s)"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Sites"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $ScriptInformation.Add(@{Data = "This published item will be available from the following Sites"; Value = $SiteName; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = ""; Value = $SiteName; }) > $Null
                                            }
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Publish from"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    If($PubItem.PublishFrom -eq "Server")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $cnt++
                                                    
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                                                    }
                                            }
                                    }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromGroup)
                                            {
                                                    $cnt++
                                                    
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = $ItemName; }) > $Null
                                                    }
                                                    Else
                                                    {
                                                            $ScriptInformation.Add(@{Data = ""; Value = $ItemName; }) > $Null
                                                    }
                                            }
                                    }
                                    Else
                                    {
                                            $ScriptInformation.Add(@{Data = "$PublishedFrom"; Value = ""; }) > $Null
                                    }
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
     
                                    WriteWordLine 3 0 "Desktop"
                                    WriteWordLine 4 0 "Desktop"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Name"; Value = $PubItem.Name; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Description"; Value = $PubItem.Description; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Connect to administrative session"; Value = $PubItem.ConnectToConsole.ToString(); }) > $Null
                                    $ScriptInformation.Add(@{Data = "Start automatically when user logs on"; Value = $PubItem.StartOnLogon.ToString(); }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                                    
                                    WriteWordLine 4 0 "Properties"
                                    $ScriptInformation = New-Object System.Collections.ArrayList
                                    $ScriptInformation.Add(@{Data = "Desktop size"; Value = $DesktopSize; }) > $Null
                                    $ScriptInformation.Add(@{Data = "Multi-Monitor"; Value = $AllowMultiMonitor; }) > $Null
     
                                    $Table = AddWordTable -Hashtable $ScriptInformation `
                                    -Columns Data,Value `
                                    -List `
                                    -Format $wdTableGrid `
                                    -AutoFit $wdAutoFitFixed;
     
                                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                                    $Table.Columns.Item(1).Width = 200;
                                    $Table.Columns.Item(2).Width = 300;
     
                                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                                    FindWordDocumentEnd
                                    $Table = $Null
                                    WriteWordLine 0 0 ""
                                    
                                    OutputPubItemFilters $PubItem "MSWordPDF"
                                    
                                    OutputPubItemShortcuts $PubItem "MSWordPDF" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                            }
                            If($Text)
                            {
                                    Line 2 "Information"
                                    Line 3 "RD Session Host Desktop`t`t`t`t`t: " "#$($PubItem.Id): $($PubItem.Name)"
                                    Line 3 "Description`t`t`t`t`t`t: " $PubItem.Description
                                    Line 3 "Last modification by`t`t`t`t`t: " $PubItem.AdminLastMod
                                    Line 3 "Modified on`t`t`t`t`t`t: " $PubItem.TimeLastMod.ToString()
                                    Line 3 "Created by`t`t`t`t`t`t: " $PubItem.AdminCreate
                                    Line 3 "Created on`t`t`t`t`t`t: " $PubItem.TimeCreate.ToString()
                                    Line 3 "Connect to administrative session`t`t`t: " $PubItem.ConnectToConsole.ToString()
                                    Line 3 "Desktop Size`t`t`t`t`t`t: " $DesktopSize
                                    
                                    If($PubItem.PublishFrom -eq "Server")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    If($cnt -eq 0)
                                                    {
                                                            Line 3 "Published from`t`t`t`t`t`t: " ItemName
                                                    }
                                                    Else
                                                    {
                                                            Line 10 $ItemName
                                                    }
                                            }
                                    }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromGroup)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    If($cnt -eq 0)
                                                    {
                                                            Line 3 "Published from`t`t`t`t`t`t: " ItemName
                                                    }
                                                    Else
                                                    {
                                                            Line 10 $ItemName
                                                    }
                                            }
                                    }
                                    Else
                                    {
                                            Line 3 "Published from`t`t`t`t`t`t: " "All Servers in Site"
                                    }
     
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    Line 3 "Create shortcut on desktop"
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($DefaultStartPath)'"
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    Line 3 "Create shortcut on desktop"
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    Line 3 "Create shortcut in Start Menu under " "'$($PubItem.StartPath)'"
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    Line 3 "Create shortcut in Auto Start Folder"
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            Line 3 "Own Filters"
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            Line 3 " User filtering is enabled"
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    Line 10 "  " $Item.Account
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            Line 3 " IP filtering is enabled"
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
                                                            }
                                                            Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    Line 10 "  " $item.From
                                                            }
                                                            Else
                                                            {
                                                                    Line 10 "  $($item.From) - $($item.To)"
                                                            }
                                                    }
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            Line 3 " Client filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            Line 3 " MAC filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            Line 3 " Gateway filtering is enabled"
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    Line 10 "  " $Item
                                            }
                                            Line 0 ""
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            Line 3 " Client device operating system filtering is enabled"
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    Line 10 "  Android"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    Line 10 "  Chrome OS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    Line 10 "  iOS/iPadOS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    Line 10 "  Linux"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    Line 10 "  macOS"
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    Line 10 "  RAS Web Portal"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    Line 10 "  Windows"
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    Line 10 "  Wyse"
                                            }
                                            Line 0 ""
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    Line 3 "Available in Site(s)`t`t`t`t`t: " $SiteName
                                            }
                                            Else
                                            {
                                                    Line 10 $SiteName
                                            }
                                    }
                                    Line 0 ""
     
                                    Line 2 "Sites"
                                    Line 3 "This published item will be available from the following Sites"
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            Line 10 $SiteName
                                    }
                                    Line 0 ""
     
                                    Line 2 "Publish from"
                                    Line 3 $PublishedFrom
                                    If($PubItem.PublishFrom -eq "Server")
                                    {
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    Line 6 $ItemName
                                            }
                                    }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                                            ForEach($Item in $PubItem.PublishFromGroup)
                                            {
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    Line 5 $ItemName
                                            }
                                    }
                                    Line 0 ""
                                    
                                    Line 2 "Desktop"
                                    Line 3 "Desktop"
                                    Line 4 "Name`t`t`t`t`t`t: " $PubItem.Name
                                    Line 4 "Description`t`t`t`t`t: " $PubItem.Description
                                    Line 4 "Connect to administrative session`t`t: " $PubItem.ConnectToConsole.ToString()
                                    Line 4 "Start automatically when user logs on`t`t: " $PubItem.StartOnLogon.ToString()
                                    Line 0 ""
                                    
                                    Line 3 "Properties"
                                    Line 4 "Desktop size`t`t`t`t`t: " $DesktopSize
                                    Line 4 "Multi-Monitor`t`t`t`t`t: " $AllowMultiMonitor
                                    Line 0 ""
     
                                    OutputPubItemFilters $PubItem "Text"
                                    
                                    OutputPubItemShortcuts $PubItem "Text" `
                                    $DefaultCreateShortcutOnDesktop `
                                    $DefaultCreateShortcutInStartFolder `
                                    $DefaultStartPath `
                                    $DefaultCreateShortcutInStartUpFolder `
                                    $DefaultReplicateShortcutSettings
                            }
                            If($HTML)
                            {
                                    WriteHTMLLine 3 0 "Information"
                                    $rowdata = @()
                                    $columnHeaders = @("RD Session Host Desktop",($Script:htmlsb),"#$($PubItem.Id): $($PubItem.Name)",$htmlwhite)
                                    $rowdata += @(,("Description",($Script:htmlsb),$PubItem.Description,$htmlwhite))
                                    $rowdata += @(,("Last modification by",($Script:htmlsb), $PubItem.AdminLastMod,$htmlwhite))
                                    $rowdata += @(,("Modified on",($Script:htmlsb), $PubItem.TimeLastMod.ToString(),$htmlwhite))
                                    $rowdata += @(,("Created by",($Script:htmlsb), $PubItem.AdminCreate,$htmlwhite))
                                    $rowdata += @(,("Created on",($Script:htmlsb), $PubItem.TimeCreate.ToString(),$htmlwhite))
                                    $rowdata += @(,("Connect to administrative session",($Script:htmlsb),$PubItem.ConnectToConsole.ToString(),$htmlwhite))
                                    $rowdata += @(,("Desktop Size",($Script:htmlsb),$DesktopSize,$htmlwhite))
                                    
                                    If($PubItem.PublishFrom -eq "Server")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    If($cnt -eq 0)
                                                    {
                                                            $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                                    }
                                            }
                                    }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromGroup)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    If($cnt -eq 0)
                                                    {
                                                            $rowdata += @(,("Published from",($Script:htmlsb),$ItemName,$htmlwhite))
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                                    }
                                            }
                                    }
                                    Else
                                    {
                                            $rowdata += @(,("Published from",($Script:htmlsb),"All Servers in Site",$htmlwhite))
                                    }
     
                                    If($PubItem.InheritShortcutDefaultSettings)
                                    {
                                            If($DefaultCreateShortcutOnDesktop -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartFolder -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($DefaultStartPath)'",$htmlwhite))
                                            }
                                            If($DefaultCreateShortcutInStartUpFolder -eq "True")
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
                                    }
                                    Else
                                    {
                                            If($PubItem.CreateShortcutOnDesktop)
                                            {
                                                    $rowdata += @(,("Create shortcut on desktop",($Script:htmlsb),"",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Start Menu under ",($Script:htmlsb),"'$($PubItem.StartPath)'",$htmlwhite))
                                            }
                                            If($PubItem.CreateShortcutInStartUpFolder)
                                            {
                                                    $rowdata += @(,("Create shortcut in Auto Start Folder",($Script:htmlsb),"",$htmlwhite))
                                            }
                                    }
     
                                    If($PubItem.UserFilterEnabled -or 
                                       $PubItem.ClientFilterEnabled -or 
                                       $PubItem.IPFilterEnabled -or 
                                       $PubItem.MACFilterEnabled -or 
                                       $PubItem.GatewayFilterEnabled -or 
                                       $PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,("Own Filters",($Script:htmlsb),"",$htmlwhite))
                                    }
     
                                    If($PubItem.UserFilterEnabled)
                                    {
                                            $rowdata += @(,(" User filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($Item in $PubItem.AllowedUsers)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item.Account,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.IPFilterEnabled)
                                    {
                                            $rowdata += @(,(" IP filtering is enabled",($Script:htmlsb),"",$htmlwhite))
     
                                            If($PubItem.AllowedIP4s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP4s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
                                                    }
                                            }
     
                                            If($PubItem.AllowedIP6s.Count -gt 0)
                                            {
                                                    ForEach($item in $PubItem.AllowedIP6s)
                                                    {
                                                            If($item.From -eq $item.To)
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),$item.From,$htmlwhite))
                                                            }
                                                            Else
                                                            {
                                                                    $rowdata += @(,("",($Script:htmlsb),"$($item.From) - $($item.To)",$htmlwhite))
                                                            }
                                                    }
                                            }
                                    }
                                    If($PubItem.ClientFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedClients)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.MACFilterEnabled)
                                    {
                                            $rowdata += @(,(" MAC filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedMACs)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.GatewayFilterEnabled)
                                    {
                                            $rowdata += @(,(" Gateway filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            ForEach($item in $PubItem.AllowedGateways)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$Item,$htmlwhite))
                                            }
                                    }
                                    If($PubItem.OSFilterEnabled)
                                    {
                                            $rowdata += @(,(" Client device operating system filtering is enabled",($Script:htmlsb),"",$htmlwhite))
                                            
                                            If($PubItem.AllowedOSes.Android)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Android",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Chrome)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.iOS)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Linux)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Linux",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Mac)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"macOS",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.WebPortal)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Windows)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Windows",$htmlwhite))
                                            }
                                            
                                            If($PubItem.AllowedOSes.Wyse)
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),"Wyse",$htmlwhite))
                                            }
                                    }
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $rowdata += @(,("Available in Site(s)",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
                                    }
                            
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Sites"
                                    $rowdata = @()
     
                                    $cnt =-1
                                    ForEach($Site in $PubItem.PublishToSite)
                                    {
                                            $cnt++
                                            $SiteName = @(Get-RASSite -Id $Site -EA 0 4>$Null).Name
                                            
                                            If($cnt -eq 0)
                                            {
                                                    $columnHeaders = @("This published item will be available from the following Sites",($Script:htmlsb),$SiteName,$htmlwhite)
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,("",($Script:htmlsb),$SiteName,$htmlwhite))
                                            }
                                    }
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
                                    WriteHTMLLine 3 0 "Publish from"
                                    $rowdata = @()
                                    If($PubItem.PublishFrom -eq "Server")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromServer)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDS -Id $Item -EA 0 4>$Null).Server
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                                    }
                                            }
                                    }
                                    ElseIf($PubItem.PublishFrom -eq "Group")
                                    {
                                            $cnt = -1
                                            ForEach($Item in $PubItem.PublishFromGroup)
                                            {
                                                    $cnt++
                                                    $ItemName = @(Get-RASRDSGroup -Id $Item -EA 0 4>$Null).Name
                                                    
                                                    If($cnt -eq 0)
                                                    {
                                                            $columnHeaders = @("$PublishedFrom",($Script:htmlsb),$ItemName,$htmlwhite)
                                                    }
                                                    Else
                                                    {
                                                            $rowdata += @(,("",($Script:htmlsb),$ItemName,$htmlwhite))
                                                    }
                                            }
                                    }
                                    Else
                                    {
                                            $columnHeaders = @("$PublishedFrom",($Script:htmlsb),"",$htmlwhite)
                                    }
     
                                    $msg = ""
                                    $columnWidths = @("200","300")
                                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                                    WriteHTMLLine 0 0 ""
     
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "ChromeApp"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "Chrome OS"; }) > $Null
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $ScriptInformation.Add(@{Data = ""; Value = "HTML5"; }) > $Null    
                                        }    
                                            
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "iOS"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "iOS/iPadOS"; }) > $Null
 
                                                $ScriptInformation.Add(@{Data = ""; Value = "RAS Web Portal"; }) > $Null <>                                                 $ScriptInformation.Add(@{Data = ""; Value = "User Portal (Web Client)"; }) > $Null
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                Line 10 "  ChromeApp" <>                                                 Line 10 "  Chrome OS"
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                Line 10 "  HTML5"    
                                        }    
                                            
 
                                                Line 10 "  iOS" <>                                                 Line 10 "  iOS/iPadOS"
 
                                   $PubItem.GWFilterEnabled -or  <>                                    $PubItem.GatewayFilterEnabled -or 
 
                                If($PubItem.GWFilterEnabled) <>                                 If($PubItem.GatewayFilterEnabled)
 
                                        ForEach($item in $PubItem.AllowedGWs) <>                                         ForEach($item in $PubItem.AllowedGateways)
 
                                                $rowdata += @(,("",($Script:htmlsb),"ChromeApp",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"Chrome OS",$htmlwhite))
 
                                        If($PubItem.AllowedOSes.HTML5) +-  
                                        {    
                                                $rowdata += @(,("",($Script:htmlsb),"HTML5",$htmlwhite))    
                                        }    
                                            
 
                                                $rowdata += @(,("",($Script:htmlsb),"iOS",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"iOS/iPadOS",$htmlwhite))
 
                                                $rowdata += @(,("",($Script:htmlsb),"RAS Web Portal",$htmlwhite)) <>                                                 $rowdata += @(,("",($Script:htmlsb),"User Portal (Web Client)",$htmlwhite))
 
  <>                         If(validObject $PubItem UserFilterReplicate)
                            {
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.UserFilterReplicate.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $PubItem.UserFilterReplicate.ToString(); }) > $Null
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 200; <>                                 $Table.Columns.Item(1).Width = 200;
                        $Table.Columns.Item(2).Width = 100;                                   $Table.Columns.Item(2).Width = 100;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
                            }
 
                                $ScriptInformation.Add(@{Data = "ChromeApp"; Value = "Enabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Chrome OS"; Value = "Enabled"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "ChromeApp"; Value = "Disabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Chrome OS"; Value = "Disabled"; }) > $Null
 
                        If($PubItem.AllowedOSes.HTML5) +-  
                        {    
                                $ScriptInformation.Add(@{Data = "HTML5"; Value = "Enabled"; }) > $Null    
                        }    
                        Else    
                        {    
                                $ScriptInformation.Add(@{Data = "HTML5"; Value = "Disabled"; }) > $Null    
                        }    
                            
 
                                $ScriptInformation.Add(@{Data = "iOS"; Value = "Enabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "iOS/iPadOS"; Value = "Enabled"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "iOS"; Value = "Disabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "iOS/iPadOS"; Value = "Disabled"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "RAS Web Portal"; Value = "Enabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "User Portal (Web Client)"; Value = "Enabled"; }) > $Null
 
                                $ScriptInformation.Add(@{Data = "RAS Web Portal"; Value = "Disabled"; }) > $Null <>                                 $ScriptInformation.Add(@{Data = "User Portal (Web Client)"; Value = "Disabled"; }) > $Null
 
                If(!($PubItem.GWFilterEnabled)) <>                 If(!($PubItem.GatewayFilterEnabled))
 
                        ForEach($item in $PubItem.AllowedGWs) <>                         ForEach($item in $PubItem.AllowedGateways)
 
  <>                         If(validObject $PubItem UserFilterReplicate)
                            {
                        Line 3 "Settings are replicated to all Sites: " $PubItem.UserFilterReplicate.ToString()                                   Line 3 "Settings are replicated to all Sites: " $PubItem.UserFilterReplicate.ToString()
                        Line 0 ""                                   Line 0 ""
                            }
 
                                Line 3 "ChromeApp`t: " "Enabled" <>                                 Line 3 "Chrome OS`t: " "Enabled"
 
                                Line 3 "ChromeApp`t: " "Disabled" <>                                 Line 3 "Chrome OS`t: " "Disabled"
                        }    
                            
                        If($PubItem.AllowedOSes.HTML5)    
                        {    
                                Line 3 "HTML5`t`t: " "Enabled"    
                        }    
                        Else    
                        {    
                                Line 3 "HTML5`t`t: " "Disabled"    
 
                If(!($PubItem.GWFilterEnabled)) <>                 If(!($PubItem.GatewayFilterEnabled))
 
                        ForEach($item in $PubItem.AllowedGWs) <>                         ForEach($item in $PubItem.AllowedGateways)
 
  <>                         If(validObject $PubItem UserFilterReplicate)
                            {
                        $rowdata = @()                                   $rowdata = @()
                        $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.UserFilterReplicate.ToString(),$htmlwhite)                                   $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$PubItem.UserFilterReplicate.ToString(),$htmlwhite)
 
                        $msg = "" <>                                 $msg = ""
                        $columnWidths = @("183","100")                                   $columnWidths = @("183","100")
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                            }
 
                                $rowdata += @(,("ChromeApp",($Script:htmlsb),"Enabled",$htmlwhite)) <>                                 $rowdata += @(,("Chrome OS",($Script:htmlsb),"Enabled",$htmlwhite))
 
                                $rowdata += @(,("ChromeApp",($Script:htmlsb),"Disabled",$htmlwhite)) <>                                 $rowdata += @(,("Chrome OS",($Script:htmlsb),"Disabled",$htmlwhite))
 
                        If($PubItem.AllowedOSes.HTML5) +-  
                        {    
                                $rowdata += @(,("HTML5",($Script:htmlsb),"Enabled",$htmlwhite))    
                        }    
                        Else    
                        {    
                                $rowdata += @(,("HTML5",($Script:htmlsb),"Disabled",$htmlwhite))    
                        }    
                            
 
                                $rowdata += @(,("iOS",($Script:htmlsb),"Enabled",$htmlwhite)) <>                                 $rowdata += @(,("iOS/iPadOS",($Script:htmlsb),"Enabled",$htmlwhite))
 
                                $rowdata += @(,("iOS",($Script:htmlsb),"Disabled",$htmlwhite)) <>                                 $rowdata += @(,("iOS/iPadOS",($Script:htmlsb),"Disabled",$htmlwhite))
 
                                $rowdata += @(,("RAS Web Portal",($Script:htmlsb),"Enabled",$htmlwhite)) <>                                 $rowdata += @(,("User Portal (Web Client)",($Script:htmlsb),"Enabled",$htmlwhite))
 
                                $rowdata += @(,("RAS Web Portal",($Script:htmlsb),"Disabled",$htmlwhite)) <>                                 $rowdata += @(,("User Portal (Web Client)",($Script:htmlsb),"Disabled",$htmlwhite))
 
                If(!($PubItem.GWFilterEnabled)) <>                 If(!($PubItem.GatewayFilterEnabled))
 
                        ForEach($item in $PubItem.AllowedGWs) <>                         ForEach($item in $PubItem.AllowedGateways)
 
  -+                 $RDSObjects     = New-Object System.Collections.ArrayList
                    $VDIHostObjects = New-Object System.Collections.ArrayList
     
 
                        $RDSobj = [PSCustomObject] @{ <>                         $RDSobjects = [PSCustomObject] @{
                                Server = "None found"                                   Server        = "None found"
                                Type = "N/A"                                   Type          = "N/A"
 
                        $RDSobj = [PSCustomObject] @{ <>                         $RDSobjects = [PSCustomObject] @{
                                Server = "None found"                                   Server        = "None found"
                                Type = "N/A"                                   Type          = "N/A"
 
  <>                         ForEach($Result in $Results)
                            {
                                    If($Result.EnablePrinting)
                                    {
                                            $State = "Enabled"
                                    }
                                    Else
                                    {
                                            $State = "Disabled"
                                    }
                                    
                        $RDSobj = [PSCustomObject] @{                                   $RDSobj = [PSCustomObject] @{
                                Server = $Results.Server                                           Server        = $Result.Server
                                Type = "RD Session Hosts"                                           Type          = "RD Session Hosts"
                                PrintingState = $Results.EnablePrinting                                           PrintingState = $State
                                    }
                                    $Null = $RDSObjects.Add($RDSobj)
                        }                   }
 
                        $VDIHostsobj = [PSCustomObject] @{ <>                         $VDIHostobjects = [PSCustomObject] @{
                                Server = "Unable to retrieve"                                   Server        = "Unable to retrieve"
                                Type = "N/A"                                   Type          = "N/A"
 
                        $VDIHostsobj = [PSCustomObject] @{ <>                         $VDIHostobjects = [PSCustomObject] @{
                                Server = "None found"                                   Server        = "None found"
                                Type = "N/A"                                   Type          = "N/A"
 
  <>                         ForEach($Result in $Results)
                            {
                                    If($Result.EnablePrinting)
                                    {
                                            $State = "Enabled"
                                    }
                                    Else
                                    {
                                            $State = "Disabled"
                                    }
                                    
                        $VDIHostsobj = [PSCustomObject] @{                                   $VDIHostsobj = [PSCustomObject] @{
                                Server = $Results.Server                                           Server        = $Result.Server
                                Type = "VDI Providers"                                           Type          = "VDI Providers"
                                PrintingState = $Results.EnablePrinting                                           PrintingState = $State
                                    }
                                    $Null = $VDIHostObjects.Add($VDIHostsobj)
 
                OutputUniversalPrintingSettings $Printingobj $RDSobj $VDIHostsobj <>                 OutputUniversalPrintingSettings $Printingobj $RDSobjects $VDIHostobjects
 
        Switch ($RDSobj.PrintingState) +-  
        {    
                $True   {$RDSPrintingState = "Enabled"; Break}    
                $False  {$RDSPrintingState = "Disabled"; Break}    
                "N/A"   {$RDSPrintingState = "N/A"; Break}    
                Default {$RDSPrintingState = "Unable to determine RD Sessions Hosts Printing State: $($RDSobj.PrintingState)"; Break}    
        }    
            
        Switch ($VDIHostsobj.PrintingState)    
        {    
                $True   {$VDIHostsPrintingState = "Enabled"; Break}    
                $False  {$VDIHostsPrintingState = "Disabled"; Break}    
                "N/A"   {$VDIHostsPrintingState = "N/A"; Break}    
                Default {$VDIHostsPrintingState = "Unable to determine VDI Hosts Printing State: $($VDIHostsobj.PrintingState)"; Break}    
        }    
     
        $RDSType = $RDSObj.Type    
        $VDIType = $VDIHostsObj.Type    
            
 
                ForEach($RDSServer in $RDSobj.Server) <>                 ForEach($obj in $RDSobj)
 
                                Server = $RDSServer <>                                 Server = $obj.Server
                                Type   = $RDSType                                   Type   = $obj.Type
                                State  = $RDSPrintingState                                   State  = $obj.PrintingState
 
                 <>        
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                                Server = $VDIServer <>                                 Server = $obj.Server
                                Type   = $VDIType                                   Type   = $obj.Type
                                State  = $VDIHostsPrintingState                                   State  = $obj.PrintingState
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite +-  
 
                ForEach($RDSServer in $RDSobj.Server) <>                 ForEach($obj in $RDSobj)
 
                                $RDSServer,  <>                                 $obj.Server, 
                                $RDSType,                                    $obj.Type, 
                                $RDSPrintingState                                   $obj.PrintingState
 
                 <>        
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                                $VDIServer,  <>                                 $obj.Server, 
                                $VDIType,                                    $obj.Type, 
                                $VDIHostsPrintingState                                   $obj.PrintingState
 
  -+  
 
                ForEach($RDSServer in $RDSobj.Server) <>                 ForEach($obj in $RDSobj)
 
                                $RDSServer,$htmlwhite, <>                                 $obj.Server,$htmlwhite,
                                $RDSType,$htmlwhite,                                   $obj.Type,$htmlwhite,
                                $RDSPrintingState,$htmlwhite)                                   $obj.PrintingState,$htmlwhite)
 
                 <>  
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                                $VDIServer,$htmlwhite, <>                                 $obj.Server,$htmlwhite,
                                $VDIType,$htmlwhite,                                   $obj.Type,$htmlwhite,
                                $VDIHostsPrintingState,$htmlwhite)                                   $obj.PrintingState,$htmlwhite)
 
                        $Table.Columns.Item(1).Width = 100; <>                         $Table.Columns.Item(1).Width = 275;
                        $Table.Columns.Item(2).Width = 275;                           $Table.Columns.Item(2).Width = 100;
 
                        $columnWidths = @("100","300") <>                         $columnWidths = @("300","100")
 
  -+                 $RDSObjects     = New-Object System.Collections.ArrayList
                    $VDIHostObjects = New-Object System.Collections.ArrayList
                    
 
                                WIAState = $False <>                                 WIAState = "Disabled"
                                TWAINState = $False                                   TWAINState = "Disabled"
 
  -+                         $Null = $RDSObjects.Add($RDSobj)
 
                                WIAState = $False <>                                 WIAState = "Disabled"
                                TWAINState = $False                                   TWAINState = "Disabled"
 
  -+                         $Null = $RDSObjects.Add($RDSobj)
 
  <>                         ForEach($Result in $Results)
                            {
                                    If($Result.EnableWIA)
                                    {
                                            $WIAState = "Enabled"
                                    }
                                    Else
                                    {
                                            $WIAState = "Disabled"
                                    }
                                    
                                    If($Result.EnableTWAIN)
                                    {
                                            $TWAINState = "Enabled"
                                    }
                                    Else
                                    {
                                            $TWAINState = "Disabled"
                                    }
     
                        $RDSobj = [PSCustomObject] @{                                   $RDSobj = [PSCustomObject] @{
                                Server = $Results.Server                                           Server = $Result.Server
                                Type = "RD Session Hosts"                                           Type = "RD Session Hosts"
                                WIAState = $Results.EnableWIA                                           WIAState = $WIAState
                                TWAINState = $Results.EnableTWAIN                                           TWAINState = $TwainState
                                    }
                                    $Null = $RDSObjects.Add($RDSobj)
 
                                WIAState = $False <>                                 WIAState = "Disabled"
                                TWAINState = $False                                   TWAINState = "Disabled"
 
  -+                         $Null = $VDIHostObjects.Add($VDIHostsobj)
 
                                WIAState = $False <>                                 WIAState = "Disabled"
                                TWAINState = $False                                   TWAINState = "Disabled"
 
  -+                         $Null = $VDIHostObjects.Add($VDIHostsobj)
 
  <>                         ForEach($Result in $Results)
                            {
                                    If($Result.EnableWIA)
                                    {
                                            $WIAState = "Enabled"
                                    }
                                    Else
                                    {
                                            $WIAState = "Disabled"
                                    }
                                    
                                    If($Result.EnableTWAIN)
                                    {
                                            $TWAINState = "Enabled"
                                    }
                                    Else
                                    {
                                            $TWAINState = "Disabled"
                                    }
     
                        $VDIHostsobj = [PSCustomObject] @{                                   $VDIHostsobj = [PSCustomObject] @{
                                Server = $Results.Server                                           Server = $Result.Server
                                Type = "VDI Providers"                                           Type = "VDI Providers"
                                WIAState = $Results.EnableWIA                                           WIAState = $WIAState
                                TWAINState = $Results.EnableTWAIN                                           TWAINState = $TWAINState
                                    }
                                    $Null = $VDIHostObjects.Add($VDIHostsobj)
 
                OutputUniversalScanningSettings $WIAobj $TWAINobj $RDSobj $VDIHostsobj <>                 OutputUniversalScanningSettings $WIAobj $TWAINobj $RDSobjects $VDIHostobjects
 
        $RDSType = $RDSObj.Type +-  
        $VDIType = $VDIHostsObj.Type    
            
 
                $cnt = -1 <>  
                ForEach($RDSServer in $RDSobj.Server)                   ForEach($obj in $RDSObj)
 
                        $cnt++ +-  
 
                                Server = $RDSServer <>                                 Server = $obj.Server
                                Type   = $RDSType                                   Type   = $obj.Type
                                State  = $RDSobj.WIAState[$cnt].ToString()                                   State  = $obj.WIAState
 
                $cnt = -1 <>  
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                        $cnt++ +-  
 
                                Server = $VDIServer <>                                 Server = $obj.Server
                                Type   = $VDIType                                   Type   = $obj.Type
                                State  = $VDIHostsobj.WIAState[$cnt].ToString()                                   State  = $obj.WIAState
 
                $cnt = -1 <>  
                ForEach($RDSServer in $RDSobj.Server)                   ForEach($obj in $RDSobj)
 
                        $cnt++ +-  
 
                                $RDSServer,  <>                                 $obj.Server, 
                                $RDSType,                                    $obj.Type, 
                                $RDSobj.WIAState[$cnt].ToString()                                   $obj.WIAState
 
                $cnt = -1 <>  
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                        $cnt++ +-  
 
                                $VDIServer,  <>                                 $obj.Server, 
                                $VDIType,                                    $obj.Type, 
                                $VDIHostsobj.WIAState[$cnt].ToString()                                   $obj.WIAState
 
  -+  
 
                $cnt = -1 <>  
                ForEach($RDSServer in $RDSobj.Server)                   ForEach($obj in $RDSobj)
 
                        $cnt++ +-  
 
                                $RDSServer,$htmlwhite, <>                                 $obj.Server,$htmlwhite,
                                $RDSType,$htmlwhite,                                   $obj.Type,$htmlwhite,
                                $RDSobj.WIAState[$cnt].ToString(),$htmlwhite)                                   $obj.WIAState,$htmlwhite)
 
                 <>        
                $cnt = -1    
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                        $cnt++ +-  
 
                                $VDIServer,$htmlwhite, <>                                 $obj.Server,$htmlwhite,
                                $VDIType,$htmlwhite,                                   $obj.Type,$htmlwhite,
                                $VDIHostsobj.WIAState[$cnt].ToString(),$htmlwhite)                                   $obj.WIAState,$htmlwhite)
 
                $cnt = -1 <>  
                ForEach($RDSServer in $RDSobj.Server)                   ForEach($obj in $RDSobj)
 
                        $cnt++ +-  
 
                                Server = $RDSServer <>                                 Server = $obj.Server
                                Type   = $RDSType                                   Type   = $obj.Type
                                State  = $RDSobj.TwainState[$cnt].ToString()                                   State  = $obj.TwainState
 
                $cnt = -1 <>  
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                        $cnt++ +-  
 
                                Server = $VDIServer <>                                 Server = $obj.Server
                                Type   = $VDIType                                   Type   = $obj.Type
                                State  = $VDIHostsobj.TwainState[$cnt].ToString()                                   State  = $obj.TwainState
 
                $cnt = -1 <>  
                ForEach($RDSServer in $RDSobj.Server)                   ForEach($obj in $RDSobj)
 
                        $cnt++ +-  
 
                                $RDSServer,  <>                                 $obj.Server, 
                                $RDSType,                                    $obj.Type, 
                                $RDSobj.TwainState[$cnt].ToString()                                   $obj.TwainState
 
                $cnt = -1 <>  
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                        $cnt++ +-  
 
                                $VDIServer,  <>                                 $obj.Server, 
                                $VDIType,                                    $obj.Type, 
                                $VDIHostsobj.TwainState[$cnt].ToString()                                   $obj.TwainState
 
  -+  
 
                $cnt = -1 <>  
                ForEach($RDSServer in $RDSobj.Server)                   ForEach($obj in $RDSobj)
 
                        $cnt++ +-  
 
                                $RDSServer,$htmlwhite, <>                                 $obj.Server,$htmlwhite,
                                $RDSType,$htmlwhite,                                   $obj.Type,$htmlwhite,
                                $RDSobj.TwainState[$cnt].ToString(),$htmlwhite)                                   $obj.TwainState,$htmlwhite)
 
                $cnt = -1 <>  
                ForEach($VDIServer in $VDIHostsobj.Server)                   ForEach($obj in $VDIHostsobj)
 
                        $cnt++ +-  
 
                                $VDIServer,$htmlwhite, <>                                 $obj.Server,$htmlwhite,
                                $VDIType,$htmlwhite,                                   $obj.Type,$htmlwhite,
                                $VDIHostsobj.TwainState[$cnt].ToString(),$htmlwhite)                                   $obj.TwainState,$htmlwhite)
 
        Write-Verbose "$(Get-Date -Format G): `tProcessing Second level authentication" <>         Write-Verbose "$(Get-Date -Format G): `tProcessing Multi-Factor authentication"
 
        $results = Get-RAS2FASetting -SiteId $Site.Id -EA 0 4>$Null <>         $MFA = Get-RASMFA -SiteId $Site.Id -EA 0 4>$Null
 
                Unable to retrieve Second level authentication information <>                 Unable to retrieve Multi-Factor authentication information
 
                        WriteWordLine 0 0 "Unable to retrieve Second level authentication information" <>                         WriteWordLine 0 0 "Unable to retrieve Multi-Factor authentication information"
 
                        Line 0 "Unable to retrieve Second level authentication information" <>                         Line 0 "Unable to retrieve Multi-Factor authentication information"
 
                        WriteHTMLLine 0 0 "Unable to retrieve Second level authentication information" <>                         WriteHTMLLine 0 0 "Unable to retrieve Multi-Factor authentication information"
 
        ElseIf($? -and $null -eq $results) <>         ElseIf($? -and $null -eq $MFA)
 
                No Second level authentication information was found <>                 No Multi-Factor authentication information was found
 
                        WriteWordLine 0 0 "No Second level authentication information was found" <>                         WriteWordLine 0 0 "No Multi-Factor authentication information was found"
 
                        Line 0 "No Second level authentication information was found" <>                         Line 0 "No Multi-Factor authentication information was found"
 
                        WriteHTMLLine 0 0 "No Second level authentication information was found" <>                         WriteHTMLLine 0 0 "No Multi-Factor authentication information was found"
 
                Output2FASetting $results <>                 OutputMFASetting $MFA
 
  <>         
 
Function Output2FASetting <> Function OutputMFASetting
 
        Param([object] $RAS2FASettings) <>         Param([object] $RASMFASettings)
 
        Write-Verbose "$(Get-Date -Format G): `t`tOutput Second level authentication" <>         Write-Verbose "$(Get-Date -Format G): `t`tOutput Multi-Factor authentication"
 
                WriteWordLine 2 0 "Multi-factor authentication" <>                 WriteWordLine 2 0 "Multi-Factor authentication"
 
                Line 1 "Multi-factor authentication" <>                 Line 1 "Multi-Factor authentication"
 
                WriteHTMLLine 2 0 "Multi-factor authentication" <>                 WriteHTMLLine 2 0 "Multi-Factor authentication"
 
  <>         ForEach($RASMFASetting in $RASMFASettings)
            {
        Switch ($RAS2FASettings.Provider)                   Switch ($RASMFASetting.Type)
        {                   {
                "None"                  {$RAS2FASettingsProvider = "None"; Break}                           "None"                  {$RASMFASettingProvider = "None"; Break}
                "Deepnet"               {$RAS2FASettingsProvider = "Deepnet"; Break}                           "Deepnet"               {$RASMFASettingProvider = "Deepnet"; Break}
                "SafeNet"               {$RAS2FASettingsProvider = "SafeNet"; Break}                           "SafeNet"               {$RASMFASettingProvider = "SafeNet"; Break}
                "Radius"                {$RAS2FASettingsProvider = "RADIUS"; Break}                           "Radius"                {$RASMFASettingProvider = "RADIUS"; Break}
                "AzureRadius"   {$RAS2FASettingsProvider = "Azure MFA server (RADIUS)"; Break}                           "AzureRadius"   {$RASMFASettingProvider = "Azure MFA server (RADIUS)"; Break}
                "DuoRadius"     {$RAS2FASettingsProvider = "Duo (RADIUS)"; Break}                           "DuoRadius"     {$RASMFASettingProvider = "Duo (RADIUS)"; Break}
                "FortiRadius"   {$RAS2FASettingsProvider = "FortiAuthenticator (RADIUS)"; Break}                           "FortiRadius"   {$RASMFASettingProvider = "FortiAuthenticator (RADIUS)"; Break}
                "TekRadius"     {$RAS2FASettingsProvider = "TekRADIUS"; Break}                           "TekRadius"     {$RASMFASettingProvider = "TekRADIUS"; Break}
                "GAuthTOTP"             {$RAS2FASettingsProvider = "Google Authenticator"; Break}                           "GAuthTOTP"             {$RASMFASettingProvider = "Google Authenticator"; Break}
                Default                 {$RAS2FASettingsProvider = "Unable to determine 2FA Provider: $($RAS2FASettings.Provider)"; Break}                           Default                 {$RASMFASettingProvider = "Unable to determine MFA Provider: $($RASMFASetting.Type)"; Break}
        }                   }
 
        If($MSWord -or $PDF) <>                 If($MSWord -or $PDF)
        {                   {
                WriteWordLine 3 0 "Provider settings"                           WriteWordLine 3 0 "Provider settings"
                $ScriptInformation = New-Object System.Collections.ArrayList                           $ScriptInformation = New-Object System.Collections.ArrayList
                $ScriptInformation.Add(@{Data = "Provider"; Value = $RAS2FASettingsProvider; }) > $Null                           $ScriptInformation.Add(@{Data = "Provider"; Value = $RASMFASettingProvider; }) > $Null
                                          
                If($RAS2FASettingsProvider -ne "None")                           If($RASMFASettingProvider -ne "None")
                {                           {
                        $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null                                   $ScriptInformation.Add(@{Data = "Settings"; Value = ""; }) > $Null
                                                          
                        If($RAS2FASettings.Provider -eq "AzureRadius")                                   If($RASMFASetting.Type -eq "AzureRadius")
                        {                                   {
                                            $ScriptInformation.Add(@{Data = "     General"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Enable MFA provider in site"; Value = $RASMFASetting.Enabled.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Name"; Value = $RASMFASetting.Name; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Description"; Value = $RASMFASetting.Description; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DisplayName; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.AzureRadiusSettings.TypeName; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Display Name"; Value = $RASMFASetting.DisplayName; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.AzureRadiusSettings.Server; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.AzureRadiusSettings.BackupServer; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                            }
                                            $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Timeout (seconds)"; Value = $RASMFASetting.Timeout; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.RadiusAttrName)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.VendorID)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
                                            $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Enable Action: $($Item.Enabled.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Description: $($Item.Description)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Action message: $($Item.ActionMessage)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                                    $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                            }
 
  <>                                 ElseIf($RASMFASetting.Type -eq "DuoRadius")
                                    {
                                            $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DisplayName; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Primary Server"; Value = $RASMFASetting.Server; }) > $Null
                                            $ScriptInformation.Add(@{Data = "          Secondary Server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                            }
                                            Else
                                            {
                                                    $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                            }
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.AzureRadiusSettings.Port; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.AzureRadiusSettings.Timeout; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.AzureRadiusSettings.Retries; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.AzureRadiusSettings.PasswordEncoding; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                }                                           }
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                }                                           }
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "DuoRadius")                                   ElseIf($RASMFASetting.Type -eq "FortiRadius")
                        {                                   {
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.DuoRadiusSettings.TypeName; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Primary Server"; Value = $RAS2FASettings.DuoRadiusSettings.Server; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Secondary Server"; Value = $RAS2FASettings.DuoRadiusSettings.BackupServer; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                }                                           }
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.DuoRadiusSettings.Port; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.DuoRadiusSettings.Timeout; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.DuoRadiusSettings.Retries; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.DuoRadiusSettings.PasswordEncoding; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                }                                           }
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                }                                           }
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "FortiRadius")                                   ElseIf($RASMFASetting.Type -eq "TekRadius")
                        {                                   {
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.FortiRadiusSettings.TypeName; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.FortiRadiusSettings.Server; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.FortiRadiusSettings.BackupServer; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                }                                           }
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.FortiRadiusSettings.Port; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.FortiRadiusSettings.Timeout; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.FortiRadiusSettings.Retries; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.FortiRadiusSettings.PasswordEncoding; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                }                                           }
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                }                                           }
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "TekRadius")                                   ElseIf($RASMFASetting.Type -eq "Radius")
                        {                                   {
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.TekRadiusSettings.TypeName; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RASMFASetting.DisplayName; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.TekRadiusSettings.Server; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RASMFASetting.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.TekRadiusSettings.BackupServer; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RASMFASetting.BackupServer; }) > $Null
                                If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null
                                }                                           }
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.TekRadiusSettings.Port; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.TekRadiusSettings.Timeout; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RASMFASetting.Timeout; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.TekRadiusSettings.Retries; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Retries"; Value = $RASMFASetting.Retries; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.TekRadiusSettings.PasswordEncoding; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RASMFASetting.PasswordEncoding; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RASMFASetting.UsernameOnly.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RASMFASetting.ForwardFirstPwdToAD.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                            $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                }                                           }
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line                                                   $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line
                                }                                           }
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "Radius")    
                        {    
                                $ScriptInformation.Add(@{Data = "          Type Name"; Value = $RAS2FASettings.RadiusSettings.TypeName; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Primary server"; Value = $RAS2FASettings.RadiusSettings.Server; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Secondary server"; Value = $RAS2FASettings.RadiusSettings.BackupServer; }) > $Null    
                                If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - active (parallel)"; }) > $Null    
                                }    
                                Else    
                                {    
                                        $ScriptInformation.Add(@{Data = "          HA mode"; Value = "Active - passive (failover)"; }) > $Null    
                                }    
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.RadiusSettings.Port; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Timeout"; Value = $RAS2FASettings.RadiusSettings.Timeout; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Retries"; Value = $RAS2FASettings.RadiusSettings.Retries; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Password Encoding"; Value = $RAS2FASettings.RadiusSettings.PasswordEncoding; }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward username only to Radius Server"; Value = $RAS2FASettings.RadiusSettings.UsernameOnly.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "          Forward the first password to Windows authentication provider"; Value = $RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString(); }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                $ScriptInformation.Add(@{Data = "     Attributes"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Attribute $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Name: $($Item.Name)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Vendor: $($Item.Vendor)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Type: $($Item.AttributeType)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Value: $($Item.Value)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                                $ScriptInformation.Add(@{Data = "     Automation"; Value = ""; }) > $Null    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $ScriptInformation.Add(@{Data = ""; Value = "Automation $cnt"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Enabled: $($Item.Enabled.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Title: $($Item.Title)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Command: $($Item.Command)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Image: $($Item.Image)"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = "     Autosend: $($Item.AutoSend.ToString())"; }) > $Null    
                                        $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Deepnet")                                   ElseIf($RASMFASetting.Type -eq "Deepnet")
                        {                                   {
                                Switch($RAS2FASettings.DeepnetSettings.AuthMode)                                           Switch($RASMFASetting.AuthMode)
                                {                                           {
                                        "MandatoryForAllUsers"                                          {$DeepNetAuthMode = "Mandatory for all users"; Break}                                                   "MandatoryForAllUsers"                                          {$DeepNetAuthMode = "Mandatory for all users"; Break}
                                        "CreateTokenForDomainAuthenticatedUsers"        {$DeepNetAuthMode = "Create token for Domain Authenticated users"; Break}                                                   "CreateTokenForDomainAuthenticatedUsers"        {$DeepNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                        "UsersWithSafeNetAcc"                                           {$DeepNetAuthMode = "Use only for users with a safe account"; Break}                                                   "UsersWithSafeNetAcc"                                           {$DeepNetAuthMode = "Use only for users with a safe account"; Break}
                                        Default                                                                         {$DeepNetAuthMode = "Deepnet mode not found: $($RAS2FASettings.DeepnetSettings.AuthMode)"; Break}                                                   Default                                                                         {$DeepNetAuthMode = "Deepnet mode not found: $($RASMFASetting.AuthMode)"; Break}
                                }                                           }
                                                                          
                                $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Type"; Value = $RAS2FASettings.DeepnetSettings.DeepnetType; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Type"; Value = $RASMFASetting.DeepnetType; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Server"; Value = $RAS2FASettings.DeepnetSettings.Server; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Server"; Value = $RASMFASetting.Server; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Port"; Value = $RAS2FASettings.DeepnetSettings.Port.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Port"; Value = $RASMFASetting.Port.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "          Enable SSL"; Value = $RAS2FASettings.DeepnetSettings.SSL.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Enable SSL"; Value = $RASMFASetting.SSL.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "          Agent"; Value = $RAS2FASettings.DeepnetSettings.DeepnetAgent; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Agent"; Value = $RASMFASetting.DeepnetAgent; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Application"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Application"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Application"; Value = $RAS2FASettings.DeepnetSettings.App; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Application"; Value = $RASMFASetting.App; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Domain"; Value = $RAS2FASettings.DeepnetSettings.DefaultDomain; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Domain"; Value = $RASMFASetting.DefaultDomain; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Mode"; Value = $DeepNetAuthMode; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Mode"; Value = $DeepNetAuthMode; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Token Type"; Value = $RAS2FASettings.DeepnetSettings.TokenType.ToString(); }) > $Null                                           $ScriptInformation.Add(@{Data = "          Token Type"; Value = $RASMFASetting.TokenType.ToString(); }) > $Null
                                $ScriptInformation.Add(@{Data = "          Allow Channels"; Value = "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Allow Channels"; Value = "Email: $($RASMFASetting.ActivateEmail.ToString())"; }) > $Null
                                $ScriptInformation.Add(@{Data = "                        "; Value = "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())"; }) > $Null                                           $ScriptInformation.Add(@{Data = "                        "; Value = "SMS: $($RASMFASetting.ActivateSMS.ToString())"; }) > $Null
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "SafeNet")                                   ElseIf($RASMFASetting.Type -eq "SafeNet")
                        {                                   {
                                Switch($RAS2FASettings.SafeNetSettings.AuthMode)                                           Switch($RASMFASetting.AuthMode)
                                {                                           {
                                        "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}                                                   "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                        "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}                                                   "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                        "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}                                                   "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                        Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}                                                   Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}
                                }                                           }
 
                                $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null <>                                         $ScriptInformation.Add(@{Data = "     Connection"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          OTP Service URL"; Value = $RAS2FASettings.SafeNetSettings.OTPServiceURL; }) > $Null                                           $ScriptInformation.Add(@{Data = "          OTP Service URL"; Value = $RASMFASetting.OTPServiceURL; }) > $Null
                                $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          Mode"; Value = $SafeNetAuthMode; }) > $Null                                           $ScriptInformation.Add(@{Data = "          Mode"; Value = $SafeNetAuthMode; }) > $Null
                                $ScriptInformation.Add(@{Data = "          TMS Web API URL"; Value = $RAS2FASettings.SafeNetSettings.TMSWebApiURL; }) > $Null                                           $ScriptInformation.Add(@{Data = "          TMS Web API URL"; Value = $RASMFASetting.TMSWebApiURL; }) > $Null
                                $ScriptInformation.Add(@{Data = "          User Repository"; Value = $RAS2FASettings.SafeNetSettings.UserRepository; }) > $Null                                           $ScriptInformation.Add(@{Data = "          User Repository"; Value = $RASMFASetting.UserRepository; }) > $Null
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")                                   ElseIf($RASMFASetting.Type -eq "GAuthTOTP")
                        {                                   {
                                Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)                                           Switch($RASMFASetting.UserEnrollment)
                                {                                           {
                                        "Allow"                 {$GAuthAllow = "Allow"; Break}                                                   "Allow"                 {$GAuthAllow = "Allow"; Break}
                                        "AllowUntil"    {$GAuthAllow = "Allow until"; Break}                                                   "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                        "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}                                                   "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                        Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}                                                   Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}
                                }                                           }
                                                                          
                                Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)                                           Switch($RASMFASetting.Tolerance)
                                {                                           {
                                        0               {$TOTPTolerance = "None"; Break}                                                   0               {$TOTPTolerance = "None"; Break}
                                        30              {$TOTPTolerance = "+/- 30 seconds"; Break}                                                   30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                        60              {$TOTPTolerance = "+/- 60 seconds"; Break}                                                   60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                        90              {$TOTPTolerance = "+/- 90 seconds"; Break}                                                   90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                        120             {$TOTPTolerance = "+/- 120 seconds"; Break}                                                   120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                        Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}                                                   Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                }                                           }
                                                                          
                                $ScriptInformation.Add(@{Data = "     Type Name"; Value = $RAS2FASettings.GAuthTOTPSettings.Type; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Type Name"; Value = $RASMFASetting.Type; }) > $Null
                                $ScriptInformation.Add(@{Data = "     User Enrollment"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     User Enrollment"; Value = ""; }) > $Null
                                If($GAuthAllow -eq "Allow until")                                           If($GAuthAllow -eq "Allow until")
                                {                                           {
                                        $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime                                                   $GAuthFullDate = $RASMFASetting.UntilDateTime
                                        $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()                                                   $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                        $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()                                                   $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                        $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = "Date: $GAuthDate"; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = "Date: $GAuthDate"; }) > $Null
                                        $ScriptInformation.Add(@{Data = ""; Value = "Time: $GAuthTime"; }) > $Null                                                   $ScriptInformation.Add(@{Data = ""; Value = "Time: $GAuthTime"; }) > $Null
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = ""; }) > $Null                                                   $ScriptInformation.Add(@{Data = "          $GAuthAllow"; Value = ""; }) > $Null
                                }                                           }
                                $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "     Authentication"; Value = ""; }) > $Null
                                $ScriptInformation.Add(@{Data = "          TOTP tolerence"; Value = $TOTPTolerance; }) > $Null                                           $ScriptInformation.Add(@{Data = "          TOTP tolerence"; Value = $TOTPTolerance; }) > $Null
                        }                                   }
 
                        If($RAS2FASettings.RestrictionMode -eq "Exclusion") <>                                 <#If($RASMFASetting.RestrictionMode -eq "Exclusion")
                        {                                   {
                                $ScriptInformation.Add(@{Data = "Enable MFA for all users except"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Enable MFA for all users except"; Value = ""; }) > $Null
                        }                                   }
                        Else                                   Else
                        {                                   {
                                $ScriptInformation.Add(@{Data = "Disable MFA for all users except"; Value = ""; }) > $Null                                           $ScriptInformation.Add(@{Data = "Disable MFA for all users except"; Value = ""; }) > $Null
                        }                                   }#>
                                                          
                        $Table = AddWordTable -Hashtable $ScriptInformation `                                   $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 250;
                        $Table.Columns.Item(2).Width = 175;                                   $Table.Columns.Item(2).Width = 175;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""
 
                        WriteWordLine 3 0 "Restriction" <>                                 <#WriteWordLine 3 0 "Restrictions"
                        $ScriptInformation = New-Object System.Collections.ArrayList                                   $ScriptInformation = New-Object System.Collections.ArrayList
                        $ScriptInformation.Add(@{Data = "User or group list"; Value = $RAS2FASettings.ExcludeUserGroup.ToString(); }) > $Null                                   $ScriptInformation.Add(@{Data = "User or group list"; Value = $RASMFASetting.ExcludeUserGroup.ToString(); }) > $Null
                        If($RAS2FASettings.ExcludeUserGroup)                                   If($RASMFASetting.ExcludeUserGroup)
                        {                                   {
                                If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)                                           If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)
                                {                                           {
                                        ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)                                                   ForEach($Item in $RASMFASetting.ExcludeUserGroupList)
                                        {                                                   {
                                                $ScriptInformation.Add(@{Data = ""; Value = "User: $($Item.Account)"; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = "User: $($Item.Account)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = "Type: $($Item.Type)"; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = "Type: $($Item.Type)"; }) > $Null
                                                $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = ""; }) > $Null
                                        }                                                   }
                                }                                           }
                        }                                   }
 
                        $ScriptInformation.Add(@{Data = "Client IP list"; Value = $RAS2FASettings.ExcludeClientIPs.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Client IP list"; Value = $RASMFASetting.ExcludeClientIPs.ToString(); }) > $Null
                        If($RAS2FASettings.ExcludeClientIPs)                                   If($RASMFASetting.ExcludeClientIPs)
                        {                                   {
                                If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)                                           If($RASMFASetting.ExcludeClientIPList.Count -gt 0)
                                {                                           {
                                        $cnt     = -1                                                   $cnt     = -1
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPList) <>                                                 ForEach($Item in $RASMFASetting.ExcludeClientIPList)
                                        {                                                   {
                                                $cnt++                                                           $cnt++
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                           $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                {                                                           {
                                                        $ScriptInformation.Add(@{Data = "     IPv4 Addresses"; Value = $tmp; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "     IPv4 Addresses"; Value = $tmp; }) > $Null
                                                }                                                           }
                                                Else                                                           Else
                                                {                                                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null
                                                }                                                           }
                                        }                                                   }
                                }                                           }
                                                                          
                                If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)                                           If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)
                                {                                           {
                                        $cnt     = -1                                                   $cnt     = -1
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List) <>                                                 ForEach($Item in $RASMFASetting.ExcludeClientIPv6List)
                                        {                                                   {
                                                $cnt++                                                           $cnt++
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                           $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                {                                                           {
                                                        $ScriptInformation.Add(@{Data = "     IPv6 Addresses"; Value = $tmp; }) > $Null                                                                   $ScriptInformation.Add(@{Data = "     IPv6 Addresses"; Value = $tmp; }) > $Null
                                                }                                                           }
                                                Else                                                           Else
                                                {                                                           {
                                                        $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null                                                                   $ScriptInformation.Add(@{Data = ""; Value = $tmp; }) > $Null
                                                }                                                           }
                                        }                                                   }
                                }                                           }
                        }                                   }
 
                        $ScriptInformation.Add(@{Data = "Client MAC list"; Value = $RAS2FASettings.ExcludeClientMAC.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Client MAC list"; Value = $RASMFASetting.ExcludeClientMAC.ToString(); }) > $Null
                        If($RAS2FASettings.ExcludeClientMAC)                                   If($RASMFASetting.ExcludeClientMAC)
                        {                                   {
                                $cnt = -1                                           $cnt = -1
                                ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)                                           ForEach($MAC in $RASMFASetting.ExcludeClientMACList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                                                                          
                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                        {                                                   {
                                                $ScriptInformation.Add(@{Data = "     MAC Address"; Value = $MAC; }) > $Null                                                           $ScriptInformation.Add(@{Data = "     MAC Address"; Value = $MAC; }) > $Null
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                $ScriptInformation.Add(@{Data = ""; Value = $MAC; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = $MAC; }) > $Null
                                        }                                                   }
                                }                                           }
                        }                                   }
 
                        $ScriptInformation.Add(@{Data = "Connection to the following Gateway IPs"; Value = $RAS2FASettings.ExcludeClientGWIPs.ToString(); }) > $Null <>                                 $ScriptInformation.Add(@{Data = "Connection to the following Gateway IPs"; Value = $RASMFASetting.ExcludeClientGWIPs.ToString(); }) > $Null
                        If($RAS2FASettings.ExcludeClientGWIPs)                                   If($RASMFASetting.ExcludeClientGWIPs)
                        {                                   {
                                $cnt = -1                                           $cnt = -1
                                ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)                                           ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                                                                          
                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                        {                                                   {
                                                $ScriptInformation.Add(@{Data = "     Server Name"; Value = $Server; }) > $Null                                                           $ScriptInformation.Add(@{Data = "     Server Name"; Value = $Server; }) > $Null
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                $ScriptInformation.Add(@{Data = ""; Value = $Server; }) > $Null                                                           $ScriptInformation.Add(@{Data = ""; Value = $Server; }) > $Null
                                        }                                                   }
                                }                                           }
                        }                                   }
 
                        $Table = AddWordTable -Hashtable $ScriptInformation ` <>                                 $Table = AddWordTable -Hashtable $ScriptInformation `
                        -Columns Data,Value `                                   -Columns Data,Value `
                        -List `                                   -List `
                        -Format $wdTableGrid `                                   -Format $wdTableGrid `
                        -AutoFit $wdAutoFitFixed;                                   -AutoFit $wdAutoFitFixed;
 
                        SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite <>                                 SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                        SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;                                   SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
 
                        $Table.Columns.Item(1).Width = 250; <>                                 $Table.Columns.Item(1).Width = 250;
                        $Table.Columns.Item(2).Width = 250;                                   $Table.Columns.Item(2).Width = 250;
 
                        $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional) <>                                 $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
 
                        FindWordDocumentEnd <>                                 FindWordDocumentEnd
                        $Table = $Null                                   $Table = $Null
                        WriteWordLine 0 0 ""                                   WriteWordLine 0 0 ""#>
                }                           }
     
                $ScriptInformation = New-Object System.Collections.ArrayList    
                $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RAS2FASettings.ReplicateSettings.ToString(); }) > $Null    
     
                $Table = AddWordTable -Hashtable $ScriptInformation `    
                -Columns Data,Value `    
                -List `    
                -Format $wdTableGrid `    
                -AutoFit $wdAutoFitFixed;    
     
                SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite    
                SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;    
     
                $Table.Columns.Item(1).Width = 250;    
                $Table.Columns.Item(2).Width = 175;    
     
                $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)    
     
                FindWordDocumentEnd    
                $Table = $Null    
                WriteWordLine 0 0 ""    
        }                   }
        If($Text)                   If($Text)
        {                   {
                Line 2 "Provider settings"                           Line 2 "Provider settings"
                Line 3 "Provider: " $RAS2FASettingsProvider                           Line 3 "Provider: " $RASMFASettingProvider
                If($RAS2FASettingsProvider -ne "None")                           If($RASMFASettingProvider -ne "None")
                {                           {
                        Line 3 "Settings"                                   Line 3 "Settings"
                                                          
                        If($RAS2FASettings.Provider -eq "AzureRadius")                                   If($RASMFASetting.Type -eq "AzureRadius")
                        {                                   {
                                            Line 4 "General"
                                            Line 5 "Enable MFA provider in site`t: " $RASMFASetting.Enabled.ToString()
                                            Line 5 "Name`t`t`t`t: " $RASMFASetting.Name
                                            Line 5 "Description`t`t`t: " $RASMFASetting.Description
                                            Line 5 "Type`t`t`t`t: " $RASMFASetting.DisplayName
                                Line 4 "Connection"                                           Line 4 "Connection"
                                            Line 5 "Display Name`t`t`t: " $RASMFASetting.DisplayName
                                            Line 5 "Primary server`t`t`t: " $RASMFASetting.Server
                                            Line 5 "Secondary server`t`t: " $RASMFASetting.BackupServer
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    Line 5 "HA mode`t`t`t`t: Active - active (parallel)"
                                            }
                                            Else
                                            {
                                                    Line 5 "HA mode`t`t`t`t: Active - passive (failover)"
                                            }
                                            Line 5 "Port`t`t`t`t: " $RASMFASetting.Port
                                            Line 5 "Timeout (seconds)`t`t: " $RASMFASetting.Timeout
                                            Line 5 "Retries`t`t`t`t: " $RASMFASetting.Retries
                                            Line 5 "Password Encoding`t`t: " $RASMFASetting.PasswordEncoding
                                            Line 5 "Forward username only to "
                                            Line 5 "Radius Server`t`t`t: " $RASMFASetting.UsernameOnly.ToString()
                                            Line 5 "Forward the first password to "
                                            Line 5 "Windows authentication provider`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                            Line 4 "Attributes"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "Attribute $cnt"
                                                    Line 6 "Name`t: $($Item.RadiusAttrName)"
                                                    Line 6 "Vendor`t: $($Item.VendorID)"
                                                    Line 6 "Type`t: $($Item.AttributeType)"
                                                    Line 6 "Value`t: $($Item.Value)"
                                                    Line 5 "" #blank separator line
                                            }
                                            Line 5 "Automation"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "Automation $cnt"
                                                    Line 6 "Enable Action`t: $($Item.Enabled.ToString())"
                                                    Line 6 "Title`t`t: $($Item.Title)"
                                                    Line 6 "Command`t`t: $($Item.Command)"
                                                    Line 6 "Description`t: $($Item.Description)"
                                                    Line 6 "Action message`t: $($Item.ActionMessage)"
                                                    Line 6 "Image`t`t: $($Item.Image)"
                                                    Line 6 "Autosend`t: $($Item.AutoSend.ToString())"
                                                    Line 6 "" #blank separator line
                                            }
                                            Line 0 ""
                                    }
                                    ElseIf($RASMFASetting.Type -eq "DuoRadius")
                                    {
                                            Line 4 "Connection"
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.TypeName                                           Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Server                                           Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.AzureRadiusSettings.BackupServer                                           Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer
                                If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"                                                   Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"                                                   Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                            }
                                            Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port
                                            Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout
                                            Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries
                                            Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding
                                            Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()
                                            Line 5 "Forward the first password to "
                                            Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                            Line 4 "Attributes"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "Attribute $cnt"
                                                    Line 6 "Name`t: $($Item.RadiusAttrName)"
                                                    Line 6 "Vendor`t: $($Item.VendorID)"
                                                    Line 6 "Type`t: $($Item.AttributeType)"
                                                    Line 6 "Value`t: $($Item.Value)"
                                                    Line 5 "" #blank separator line
                                            }
                                            Line 4 "Automation"
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    Line 5 "" "Automation $cnt"
                                                    Line 6 "Enable Action`t: $($Item.Enabled.ToString())"
                                                    Line 6 "Title`t`t: $($Item.Title)"
                                                    Line 6 "Command`t`t: $($Item.Command)"
                                                    Line 6 "Description`t: $($Item.Description)"
                                                    Line 6 "Action message`t: $($Item.ActionMessage)"
                                                    Line 6 "Image`t`t: $($Item.Image)"
                                                    Line 6 "Autosend`t: $($Item.AutoSend.ToString())"
                                                    Line 5 "" "" #blank separator line
                                            }
                                            Line 0 ""
 
  <>                                 ElseIf($RASMFASetting.Type -eq "FortiRadius")
                                    {
                                            Line 4 "Connection"
                                            Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName
                                            Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server
                                            Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                            }
                                            Else
                                            {
                                                    Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                            }
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Port                                           Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Timeout                                           Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.AzureRadiusSettings.Retries                                           Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.AzureRadiusSettings.PasswordEncoding                                           Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString()                                           Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()
                                Line 5 "Forward the first password to "                                           Line 5 "Forward the first password to "
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString()                                           Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                Line 4 "Attributes"                                           Line 4 "Attributes"
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        Line 5 "Attribute $cnt"                                                   Line 5 "Attribute $cnt"
                                        Line 6 "Name  : $($Item.Name)"                                                   Line 6 "Name  : $($Item.Name)"
                                        Line 6 "Vendor: $($Item.Vendor)"                                                   Line 6 "Vendor: $($Item.Vendor)"
                                        Line 6 "Type  : $($Item.AttributeType)"                                                   Line 6 "Type  : $($Item.AttributeType)"
                                        Line 6 "Value : $($Item.Value)"                                                   Line 6 "Value : $($Item.Value)"
                                        Line 5 "" #blank separator line                                                   Line 5 "" #blank separator line
                                }                                           }
                                Line 4 "Automation"                                           Line 4 "Automation"
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        Line 5 "" "Automation $cnt"                                                   Line 5 "" "Automation $cnt"
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"                                                   Line 6 "Enabled : $($Item.Enabled.ToString())"
                                        Line 6 "Title   : $($Item.Title)"                                                   Line 6 "Title   : $($Item.Title)"
                                        Line 6 "Command : $($Item.Command)"                                                   Line 6 "Command : $($Item.Command)"
                                        Line 6 "Image   : $($Item.Image)"                                                   Line 6 "Image   : $($Item.Image)"
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"                                                   Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                        Line 5 "" "" #blank separator line                                                   Line 5 "" "" #blank separator line
                                }                                           }
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "DuoRadius")                                   ElseIf($RASMFASetting.Type -eq "TekRadius")
                        {                                   {
                                Line 4 "Connection"                                           Line 4 "Connection"
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.TypeName                                           Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Server                                           Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.DuoRadiusSettings.BackupServer                                           Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer
                                If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"                                                   Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"                                                   Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                }                                           }
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Port                                           Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Timeout                                           Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.DuoRadiusSettings.Retries                                           Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.DuoRadiusSettings.PasswordEncoding                                           Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString()                                           Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()
                                Line 5 "Forward the first password to "                                           Line 5 "Forward the first password to "
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString()                                           Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                Line 4 "Attributes"                                           Line 4 "Attributes"
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        Line 5 "Attribute $cnt"                                                   Line 5 "Attribute $cnt"
                                        Line 6 "Name  : $($Item.Name)"                                                   Line 6 "Name  : $($Item.Name)"
                                        Line 6 "Vendor: $($Item.Vendor)"                                                   Line 6 "Vendor: $($Item.Vendor)"
                                        Line 6 "Type  : $($Item.AttributeType)"                                                   Line 6 "Type  : $($Item.AttributeType)"
                                        Line 6 "Value : $($Item.Value)"                                                   Line 6 "Value : $($Item.Value)"
                                        Line 5 "" #blank separator line                                                   Line 5 "" #blank separator line
                                }                                           }
                                Line 4 "Automation"                                           Line 4 "Automation"
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        Line 5 "" "Automation $cnt"                                                   Line 5 "" "Automation $cnt"
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"                                                   Line 6 "Enabled : $($Item.Enabled.ToString())"
                                        Line 6 "Title   : $($Item.Title)"                                                   Line 6 "Title   : $($Item.Title)"
                                        Line 6 "Command : $($Item.Command)"                                                   Line 6 "Command : $($Item.Command)"
                                        Line 6 "Image   : $($Item.Image)"                                                   Line 6 "Image   : $($Item.Image)"
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"                                                   Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                        Line 5 "" "" #blank separator line                                                   Line 5 "" "" #blank separator line
                                }                                           }
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "FortiRadius")                                   ElseIf($RASMFASetting.Type -eq "Radius")
                        {                                   {
                                Line 4 "Connection"                                           Line 4 "Connection"
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.TypeName                                           Line 5 "Type Name`t`t`t`t: " $RASMFASetting.DisplayName
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Server                                           Line 5 "Primary Server`t`t`t`t: " $RASMFASetting.Server
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.FortiRadiusSettings.BackupServer                                           Line 5 "Secondary server`t`t`t: " $RASMFASetting.BackupServer
                                If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"                                                   Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"                                                   Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"
                                }                                           }
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Port                                           Line 5 "Port`t`t`t`t`t: " $RASMFASetting.Port
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Timeout                                           Line 5 "Timeout`t`t`t`t`t: " $RASMFASetting.Timeout
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.FortiRadiusSettings.Retries                                           Line 5 "Retries`t`t`t`t`t: " $RASMFASetting.Retries
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.FortiRadiusSettings.PasswordEncoding                                           Line 5 "Password Encoding`t`t`t: " $RASMFASetting.PasswordEncoding
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString()                                           Line 5 "Forward username only to Radius Server`t: " $RASMFASetting.UsernameOnly.ToString()
                                Line 5 "Forward the first password to "                                           Line 5 "Forward the first password to "
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString()                                           Line 5 "Windows authentication provider`t`t: " $RASMFASetting.ForwardFirstPwdToAD.ToString()
                                Line 4 "Attributes"                                           Line 4 "Attributes"
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        Line 5 "Attribute $cnt"                                                   Line 5 "Attribute $cnt"
                                        Line 6 "Name  : $($Item.Name)"                                                   Line 6 "Name  : $($Item.Name)"
                                        Line 6 "Vendor: $($Item.Vendor)"                                                   Line 6 "Vendor: $($Item.Vendor)"
                                        Line 6 "Type  : $($Item.AttributeType)"                                                   Line 6 "Type  : $($Item.AttributeType)"
                                        Line 6 "Value : $($Item.Value)"                                                   Line 6 "Value : $($Item.Value)"
                                        Line 5 "" #blank separator line                                                   Line 5 "" #blank separator line
                                }                                           }
                                Line 4 "Automation"                                           Line 4 "Automation"
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        Line 5 "" "Automation $cnt"                                                   Line 5 "" "Automation $cnt"
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"                                                   Line 6 "Enabled : $($Item.Enabled.ToString())"
                                        Line 6 "Title   : $($Item.Title)"                                                   Line 6 "Title   : $($Item.Title)"
                                        Line 6 "Command : $($Item.Command)"                                                   Line 6 "Command : $($Item.Command)"
                                        Line 6 "Image   : $($Item.Image)"                                                   Line 6 "Image   : $($Item.Image)"
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"                                                   Line 6 "Autosend: $($Item.AutoSend.ToString())"
                                        Line 5 "" "" #blank separator line                                                   Line 5 "" "" #blank separator line
                                }                                           }
                                Line 0 ""                                           Line 0 ""
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "TekRadius")    
                        {    
                                Line 4 "Connection"    
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.TypeName    
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Server    
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.TekRadiusSettings.BackupServer    
                                If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"    
                                }    
                                Else    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"    
                                }    
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Port    
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Timeout    
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.TekRadiusSettings.Retries    
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.TekRadiusSettings.PasswordEncoding    
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString()    
                                Line 5 "Forward the first password to "    
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString()    
                                Line 4 "Attributes"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "Attribute $cnt"    
                                        Line 6 "Name  : $($Item.Name)"    
                                        Line 6 "Vendor: $($Item.Vendor)"    
                                        Line 6 "Type  : $($Item.AttributeType)"    
                                        Line 6 "Value : $($Item.Value)"    
                                        Line 5 "" #blank separator line    
                                }    
                                Line 4 "Automation"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "" "Automation $cnt"    
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"    
                                        Line 6 "Title   : $($Item.Title)"    
                                        Line 6 "Command : $($Item.Command)"    
                                        Line 6 "Image   : $($Item.Image)"    
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"    
                                        Line 5 "" "" #blank separator line    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Radius")    
                        {    
                                Line 4 "Connection"    
                                Line 5 "Type Name`t`t`t`t: " $RAS2FASettings.RadiusSettings.TypeName    
                                Line 5 "Primary Server`t`t`t`t: " $RAS2FASettings.RadiusSettings.Server    
                                Line 5 "Secondary server`t`t`t: " $RAS2FASettings.RadiusSettings.BackupServer    
                                If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - active (parallel)"    
                                }    
                                Else    
                                {    
                                        Line 5 "HA mode`t`t`t`t`t: " "Active - passive (failover)"    
                                }    
                                Line 5 "Port`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Port    
                                Line 5 "Timeout`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Timeout    
                                Line 5 "Retries`t`t`t`t`t: " $RAS2FASettings.RadiusSettings.Retries    
                                Line 5 "Password Encoding`t`t`t: " $RAS2FASettings.RadiusSettings.PasswordEncoding    
                                Line 5 "Forward username only to Radius Server`t: " $RAS2FASettings.RadiusSettings.UsernameOnly.ToString()    
                                Line 5 "Forward the first password to "    
                                Line 5 "Windows authentication provider`t`t: " $RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString()    
                                Line 4 "Attributes"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "Attribute $cnt"    
                                        Line 6 "Name  : $($Item.Name)"    
                                        Line 6 "Vendor: $($Item.Vendor)"    
                                        Line 6 "Type  : $($Item.AttributeType)"    
                                        Line 6 "Value : $($Item.Value)"    
                                        Line 5 "" #blank separator line    
                                }    
                                Line 4 "Automation"    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        Line 5 "" "Automation $cnt"    
                                        Line 6 "Enabled : $($Item.Enabled.ToString())"    
                                        Line 6 "Title   : $($Item.Title)"    
                                        Line 6 "Command : $($Item.Command)"    
                                        Line 6 "Image   : $($Item.Image)"    
                                        Line 6 "Autosend: $($Item.AutoSend.ToString())"    
                                        Line 5 "" "" #blank separator line    
                                }    
                                Line 0 ""    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Deepnet")                                   ElseIf($RASMFASetting.Type -eq "Deepnet")
                        {                                   {
                                Line 4 "Connection"                                           Line 4 "Connection"
                                Line 5 "Type`t`t: " $RAS2FASettings.DeepnetSettings.DeepnetType                                           Line 5 "Type`t`t: " $RASMFASetting.DeepnetType
                                Line 5 "Server`t`t: " $RAS2FASettings.DeepnetSettings.Server                                           Line 5 "Server`t`t: " $RASMFASetting.Server
                                Line 5 "Port`t`t: " $RAS2FASettings.DeepnetSettings.Port.ToString()                                           Line 5 "Port`t`t: " $RASMFASetting.Port.ToString()
                                Line 5 "Enable SSL`t: " $RAS2FASettings.DeepnetSettings.SSL.ToString()                                           Line 5 "Enable SSL`t: " $RASMFASetting.SSL.ToString()
                                Line 5 "Agent`t`t: " $RAS2FASettings.DeepnetSettings.DeepnetAgent                                           Line 5 "Agent`t`t: " $RASMFASetting.DeepnetAgent
                                Line 4 "Application"                                           Line 4 "Application"
                                Line 5 "          Application`t: " $RAS2FASettings.DeepnetSettings.App                                           Line 5 "          Application`t: " $RASMFASetting.App
                                Line 5 "          Domain`t: " $RAS2FASettings.DeepnetSettings.DefaultDomain                                           Line 5 "          Domain`t: " $RASMFASetting.DefaultDomain
                                Line 4 "Authentication"                                           Line 4 "Authentication"
                                Line 5 "          Mode`t`t: " $DeepNetAuthMode                                           Line 5 "          Mode`t`t: " $DeepNetAuthMode
                                Line 5 "          Token Type`t: " $RAS2FASettings.DeepnetSettings.TokenType.ToString()                                           Line 5 "          Token Type`t: " $RASMFASetting.TokenType.ToString()
                                Line 5 "          Allow Channels: " "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())"                                           Line 5 "          Allow Channels: " "Email: $($RASMFASetting.ActivateEmail.ToString())"
                                Line 5 "                          " "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())"                                           Line 5 "                          " "SMS: $($RASMFASetting.ActivateSMS.ToString())"
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "SafeNet")                                   ElseIf($RASMFASetting.Type -eq "SafeNet")
                        {                                   {
                                Switch($RAS2FASettings.SafeNetSettings.AuthMode)                                           Switch($RASMFASetting.AuthMode)
                                {                                           {
                                        "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}                                                   "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                        "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}                                                   "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                        "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}                                                   "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                        Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}                                                   Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}
                                }                                           }
 
                                Line 4 "Connection" <>                                         Line 4 "Connection"
                                Line 5 "OTP Service URL : " $RAS2FASettings.SafeNetSettings.DeepnetType                                           Line 5 "OTP Service URL : " $RASMFASetting.DeepnetType
                                Line 4 "Authentication"                                           Line 4 "Authentication"
                                Line 5 "Mode`t`t`t: " $SafeNetAuthMode                                           Line 5 "Mode`t`t`t: " $SafeNetAuthMode
                                Line 5 "TMS Web API URL`t`t: " $RAS2FASettings.SafeNetSettings.TMSWebApiURL                                           Line 5 "TMS Web API URL`t`t: " $RASMFASetting.TMSWebApiURL
                                Line 5 "User Repository`t`t: " $RAS2FASettings.SafeNetSettings.UserRepository                                           Line 5 "User Repository`t`t: " $RASMFASetting.UserRepository
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")                                   ElseIf($RASMFASetting.Type -eq "GAuthTOTP")
                        {                                   {
                                Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)                                           Switch($RASMFASetting.UserEnrollment)
                                {                                           {
                                        "Allow"                 {$GAuthAllow = "Allow"; Break}                                                   "Allow"                 {$GAuthAllow = "Allow"; Break}
                                        "AllowUntil"    {$GAuthAllow = "Allow until"; Break}                                                   "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                        "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}                                                   "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                        Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}                                                   Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}
                                }                                           }
                                                                          
                                Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)                                           Switch($RASMFASetting.Tolerance)
                                {                                           {
                                        0               {$TOTPTolerance = "None"; Break}                                                   0               {$TOTPTolerance = "None"; Break}
                                        30              {$TOTPTolerance = "+/- 30 seconds"; Break}                                                   30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                        60              {$TOTPTolerance = "+/- 60 seconds"; Break}                                                   60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                        90              {$TOTPTolerance = "+/- 90 seconds"; Break}                                                   90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                        120             {$TOTPTolerance = "+/- 120 seconds"; Break}                                                   120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                        Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}                                                   Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                }                                           }
                                                                          
                                Line 4 "Type Name: " $RAS2FASettings.GAuthTOTPSettings.Type                                           Line 4 "Type Name: " $RASMFASetting.Type
                                Line 4 "User Enrollment"                                           Line 4 "User Enrollment"
                                Line 5 $GAuthAllow                                           Line 5 $GAuthAllow
                                If($GAuthAllow -eq "Allow until")                                           If($GAuthAllow -eq "Allow until")
                                {                                           {
                                        $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime                                                   $GAuthFullDate = $RASMFASetting.UntilDateTime
                                        $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()                                                   $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                        $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()                                                   $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                        Line 6 "Date: " $GAuthDate                                                   Line 6 "Date: " $GAuthDate
                                        Line 6 "Time: " $GAuthTime                                                   Line 6 "Time: " $GAuthTime
                                }                                           }
                                Line 4 "Authentication"                                           Line 4 "Authentication"
                                Line 5 "TOTP tolerence: " $TOTPTolerance                                           Line 5 "TOTP tolerence: " $TOTPTolerance
                        }                                   }
 
                        If($RAS2FASettings.RestrictionMode -eq "Exclusion") <>                                 <#If($RASMFASetting.RestrictionMode -eq "Exclusion")
                        {                                   {
                                Line 3 "Enable MFA for all users except"                                           Line 3 "Enable MFA for all users except"
                        }                                   }
                        Else                                   Else
                        {                                   {
                                Line 3 "Disable MFA for all users except"                                           Line 3 "Disable MFA for all users except"
                        }                                   }#>
                        Line 0 ""                                   Line 0 ""
 
                        Line 2 "Restriction" <>                                 <#Line 2 "Restriction"
                        Line 3 "User or group list`t`t`t: " $RAS2FASettings.ExcludeUserGroup.ToString()                                   Line 3 "User or group list`t`t`t: " $RASMFASetting.ExcludeUserGroup.ToString()
                        If($RAS2FASettings.ExcludeUserGroup)                                   If($RASMFASetting.ExcludeUserGroup)
                        {                                   {
                                If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)                                           If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)
                                {                                           {
                                        ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)                                                   ForEach($Item in $RASMFASetting.ExcludeUserGroupList)
                                        {                                                   {
                                                Line 8 "  " "User: $($Item.Account)"                                                           Line 8 "  " "User: $($Item.Account)"
                                                Line 8 "  " "Type: $($Item.Type)"                                                           Line 8 "  " "Type: $($Item.Type)"
                                                Line 8 "  "                                                           Line 8 "  "
                                        }                                                   }
                                }                                           }
                        }                                   }
                                                                          
                        Line 3 "Client IP list`t`t`t`t: " $RAS2FASettings.ExcludeClientIPs.ToString()                                   Line 3 "Client IP list`t`t`t`t: " $RASMFASetting.ExcludeClientIPs.ToString()
                        If($RAS2FASettings.ExcludeClientIPs)                                   If($RASMFASetting.ExcludeClientIPs)
                        {                                   {
                                If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)                                           If($RASMFASetting.ExcludeClientIPList.Count -gt 0)
                                {                                           {
                                        $cnt     = -1                                                   $cnt     = -1
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPList) <>                                                 ForEach($Item in $RASMFASetting.ExcludeClientIPList)
                                        {                                                   {
                                                $cnt++                                                           $cnt++
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                           $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                {                                                           {
                                                        Line 6 "IPv4 Addresses`t: " $tmp                                                                   Line 6 "IPv4 Addresses`t: " $tmp
                                                }                                                           }
                                                Else                                                           Else
                                                {                                                           {
                                                        Line 8 "  " $tmp                                                                   Line 8 "  " $tmp
                                                }                                                           }
                                        }                                                   }
                                }                                           }
                                                                          
                                If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)                                           If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)
                                {                                           {
                                        $cnt     = -1                                                   $cnt     = -1
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List) <>                                                 ForEach($Item in $RASMFASetting.ExcludeClientIPv6List)
                                        {                                                   {
                                                $cnt++                                                           $cnt++
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                           $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                {                                                           {
                                                        Line 6 "IPv6 Addresses`t: " $tmp                                                                   Line 6 "IPv6 Addresses`t: " $tmp
                                                }                                                           }
                                                Else                                                           Else
                                                {                                                           {
                                                        Line 8 "  " $tmp                                                                   Line 8 "  " $tmp
                                                }                                                           }
                                        }                                                   }
                                }                                           }
                        }                                   }
                        Line 3 "Client MAC list`t`t`t`t: " $RAS2FASettings.ExcludeClientMAC.ToString()                                   Line 3 "Client MAC list`t`t`t`t: " $RASMFASetting.ExcludeClientMAC.ToString()
                        If($RAS2FASettings.ExcludeClientMAC)                                   If($RASMFASetting.ExcludeClientMAC)
                        {                                   {
                                $cnt = -1                                           $cnt = -1
                                ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)                                           ForEach($MAC in $RASMFASetting.ExcludeClientMACList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                                                                          
                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                        {                                                   {
                                                Line 6 "MAC Address`t: " $MAC                                                           Line 6 "MAC Address`t: " $MAC
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                Line 8 "  " $MAC                                                           Line 8 "  " $MAC
                                        }                                                   }
                                }                                           }
                        }                                   }
                        Line 3 "Connection to the following Gateway IPs`t: " $RAS2FASettings.ExcludeClientGWIPs.ToString()                                   Line 3 "Connection to the following Gateway IPs`t: " $RASMFASetting.ExcludeClientGWIPs.ToString()
                        If($RAS2FASettings.ExcludeClientGWIPs)                                   If($RASMFASetting.ExcludeClientGWIPs)
                        {                                   {
                                $cnt = -1                                           $cnt = -1
                                ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)                                           ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                                                                          
                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                        {                                                   {
                                                Line 6 "Server Name`t: " $Server                                                           Line 6 "Server Name`t: " $Server
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                Line 8 "  " $Server                                                           Line 8 "  " $Server
                                        }                                                   }
                                }                                           }
                        }                                   }#>
                }                           }
                Line 0 ""                           Line 0 ""
                Line 2 "Settings are replicated to all Sites`t`t: " $RAS2FASettings.ReplicateSettings.ToString()    
                Line 0 ""    
        }                   }
        If($HTML)                   If($HTML)
        {                   {
                $rowdata = @()                           $rowdata = @()
                $columnHeaders = @("Provider",($Script:htmlsb),$RAS2FASettingsProvider,$htmlwhite)                           $columnHeaders = @("Provider",($Script:htmlsb),$RASMFASettingProvider,$htmlwhite)
                If($RAS2FASettingsProvider -ne "None")                           If($RASMFASettingProvider -ne "None")
                {                           {
                        If($RAS2FASettings.Provider -eq "AzureRadius")                                   If($RASMFASetting.Type -eq "AzureRadius")
                        {                                   {
                                            $rowdata += @(,( "     General",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("          Enable MFA provider in site",($Script:htmlsb),$RASMFASetting.Enabled.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Name",($Script:htmlsb),$RASMFASetting.Name,$htmlwhite))
                                            $rowdata += @(,("          Description",($Script:htmlsb), $RASMFASetting.Description,$htmlwhite))
                                            $rowdata += @(,("          Type",($Script:htmlsb), $RASMFASetting.DisplayName,$htmlwhite))
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.TypeName,$htmlwhite))                                           $rowdata += @(,("          Display Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Server,$htmlwhite))                                           $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                $rowdata += @(,("          Secondary server",($Script:htmlsb), $RAS2FASettings.AzureRadiusSettings.BackupServer,$htmlwhite))                                           $rowdata += @(,("          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                If($RAS2FASettings.AzureRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))                                                   $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))                                                   $rowdata += @(,("          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                            }
                                            $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                            $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                            $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                            $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                            $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                            $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AttributeInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.RadiusAttrName)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.VendorID)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
                                            $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                            $cnt=0
                                            ForEach($Item in $RASMFASetting.AutomationInfoList)
                                            {
                                                    $cnt++
                                                    $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Enabled Action: $($Item.Enabled.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Description: $($Item.Description)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Action message: $($Item.ActionMessage)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                                    $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                            }
 
  <>                                 ElseIf($RASMFASetting.Type -eq "DuoRadius")
                                    {
                                            $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                            $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                            $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                            $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                            If($RASMFASetting.HAMode -eq "Parallel")
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                            }
                                            Else
                                            {
                                                    $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                            }
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Port,$htmlwhite))                                           $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Timeout,$htmlwhite))                                           $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.Retries,$htmlwhite))                                           $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))                                           $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.UsernameOnly.ToString(),$htmlwhite))                                           $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.AzureRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))                                           $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                }                                           }
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.AzureRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                }                                           }
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "DuoRadius")                                   ElseIf($RASMFASetting.Type -eq "FortiRadius")
                        {                                   {
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.TypeName,$htmlwhite))                                           $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Server,$htmlwhite))                                           $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.DuoRadiusSettings.BackupServer,$htmlwhite))                                           $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                If($RAS2FASettings.DuoRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))                                                   $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))                                                   $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                }                                           }
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Port,$htmlwhite))                                           $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Timeout,$htmlwhite))                                           $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.Retries,$htmlwhite))                                           $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))                                           $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.UsernameOnly.ToString(),$htmlwhite))                                           $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.DuoRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))                                           $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                }                                           }
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.DuoRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                }                                           }
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "FortiRadius")                                   ElseIf($RASMFASetting.Type -eq "TekRadius")
                        {                                   {
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.TypeName,$htmlwhite))                                           $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Server,$htmlwhite))                                           $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.FortiRadiusSettings.BackupServer,$htmlwhite))                                           $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                If($RAS2FASettings.FortiRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))                                                   $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))                                                   $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                }                                           }
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Port,$htmlwhite))                                           $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Timeout,$htmlwhite))                                           $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.Retries,$htmlwhite))                                           $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))                                           $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.UsernameOnly.ToString(),$htmlwhite))                                           $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.FortiRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))                                           $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                }                                           }
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.FortiRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                }                                           }
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "TekRadius")                                   ElseIf($RASMFASetting.Type -eq "Radius")
                        {                                   {
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.TypeName,$htmlwhite))                                           $rowdata += @(,("          Type Name",($Script:htmlsb),$RASMFASetting.DisplayName,$htmlwhite))
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Server,$htmlwhite))                                           $rowdata += @(,("          Primary Server",($Script:htmlsb),$RASMFASetting.Server,$htmlwhite))
                                $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.TekRadiusSettings.BackupServer,$htmlwhite))                                           $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RASMFASetting.BackupServer,$htmlwhite))
                                If($RAS2FASettings.TekRadiusSettings.HAMode -eq "Parallel")                                           If($RASMFASetting.HAMode -eq "Parallel")
                                {                                           {
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))                                                   $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))                                                   $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))
                                }                                           }
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Port,$htmlwhite))                                           $rowdata += @(,("          Port",($Script:htmlsb),$RASMFASetting.Port,$htmlwhite))
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Timeout,$htmlwhite))                                           $rowdata += @(,("          Timeout",($Script:htmlsb),$RASMFASetting.Timeout,$htmlwhite))
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.Retries,$htmlwhite))                                           $rowdata += @(,("          Retries",($Script:htmlsb),$RASMFASetting.Retries,$htmlwhite))
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.PasswordEncoding.ToString(),$htmlwhite))                                           $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RASMFASetting.PasswordEncoding.ToString(),$htmlwhite))
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.UsernameOnly.ToString(),$htmlwhite))                                           $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RASMFASetting.UsernameOnly.ToString(),$htmlwhite))
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.TekRadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))                                           $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RASMFASetting.ForwardFirstPwdToAD.ToString(),$htmlwhite))
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AttributeInfoList)                                           ForEach($Item in $RASMFASetting.AttributeInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                }                                           }
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))
                                $cnt=0                                           $cnt=0
                                ForEach($Item in $RAS2FASettings.TekRadiusSettings.AutomationInfoList)                                           ForEach($Item in $RASMFASetting.AutomationInfoList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line                                                   $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line
                                }                                           }
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "Radius")    
                        {    
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))    
                                $rowdata += @(,("          Type Name",($Script:htmlsb),$RAS2FASettings.RadiusSettings.TypeName,$htmlwhite))    
                                $rowdata += @(,("          Primary Server",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Server,$htmlwhite))    
                                $rowdata += @(,( "          Secondary server",($Script:htmlsb), $RAS2FASettings.RadiusSettings.BackupServer,$htmlwhite))    
                                If($RAS2FASettings.RadiusSettings.HAMode -eq "Parallel")    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - active (parallel)",$htmlwhite))    
                                }    
                                Else    
                                {    
                                        $rowdata += @(,( "          HA mode",($Script:htmlsb), "Active - passive (failover)",$htmlwhite))    
                                }    
                                $rowdata += @(,("          Port",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Port,$htmlwhite))    
                                $rowdata += @(,("          Timeout",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Timeout,$htmlwhite))    
                                $rowdata += @(,("          Retries",($Script:htmlsb),$RAS2FASettings.RadiusSettings.Retries,$htmlwhite))    
                                $rowdata += @(,("          Password Encoding",($Script:htmlsb),$RAS2FASettings.RadiusSettings.PasswordEncoding.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward username only to Radius Server",($Script:htmlsb),$RAS2FASettings.RadiusSettings.UsernameOnly.ToString(),$htmlwhite))    
                                $rowdata += @(,("          Forward the first password to Windows authentication provider",($Script:htmlsb),$RAS2FASettings.RadiusSettings.ForwardFirstPwdToAD.ToString(),$htmlwhite))    
                                $rowdata += @(,( "     Attributes",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AttributeInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Attribute $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Name: $($Item.Name)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Vendor: $($Item.Vendor)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Type: $($Item.AttributeType)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Value: $($Item.Value)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                                $rowdata += @(,( "     Automation",($Script:htmlsb),"",$htmlwhite))    
                                $cnt=0    
                                ForEach($Item in $RAS2FASettings.RadiusSettings.AutomationInfoList)    
                                {    
                                        $cnt++    
                                        $rowdata += @(,( "",($Script:htmlsb), "Automation $cnt",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Enabled: $($Item.Enabled.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Title: $($Item.Title)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Command: $($Item.Command)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Image: $($Item.Image)",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "     Autosend: $($Item.AutoSend.ToString())",$htmlwhite))    
                                        $rowdata += @(,( "",($Script:htmlsb), "",$htmlwhite)) #blank separator line    
                                }    
                        }    
                        ElseIf($RAS2FASettings.Provider -eq "Deepnet")                                   ElseIf($RASMFASetting.Type -eq "Deepnet")
                        {                                   {
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,( "          Type",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DeepnetType,$htmlwhite))                                           $rowdata += @(,( "          Type",($Script:htmlsb), $RASMFASetting.DeepnetType,$htmlwhite))
                                $rowdata += @(,( "          Server",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.Server,$htmlwhite))                                           $rowdata += @(,( "          Server",($Script:htmlsb), $RASMFASetting.Server,$htmlwhite))
                                $rowdata += @(,( "          Port",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.Port.ToString(),$htmlwhite))                                           $rowdata += @(,( "          Port",($Script:htmlsb), $RASMFASetting.Port.ToString(),$htmlwhite))
                                $rowdata += @(,( "          Enable SSL",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.SSL.ToString(),$htmlwhite))                                           $rowdata += @(,( "          Enable SSL",($Script:htmlsb), $RASMFASetting.SSL.ToString(),$htmlwhite))
                                $rowdata += @(,( "          Agent",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DeepnetAgent,$htmlwhite))                                           $rowdata += @(,( "          Agent",($Script:htmlsb), $RASMFASetting.DeepnetAgent,$htmlwhite))
                                $rowdata += @(,( "     Application",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Application",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,( "          Application",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.App,$htmlwhite))                                           $rowdata += @(,( "          Application",($Script:htmlsb), $RASMFASetting.App,$htmlwhite))
                                $rowdata += @(,( "          Domain",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.DefaultDomain,$htmlwhite))                                           $rowdata += @(,( "          Domain",($Script:htmlsb), $RASMFASetting.DefaultDomain,$htmlwhite))
                                $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,( "          Mode",($Script:htmlsb), $DeepNetAuthMode,$htmlwhite))                                           $rowdata += @(,( "          Mode",($Script:htmlsb), $DeepNetAuthMode,$htmlwhite))
                                $rowdata += @(,( "          Token Type",($Script:htmlsb), $RAS2FASettings.DeepnetSettings.TokenType.ToString(),$htmlwhite))                                           $rowdata += @(,( "          Token Type",($Script:htmlsb), $RASMFASetting.TokenType.ToString(),$htmlwhite))
                                $rowdata += @(,( "          Allow Channels",($Script:htmlsb), "Email: $($RAS2FASettings.DeepnetSettings.ActivateEmail.ToString())",$htmlwhite))                                           $rowdata += @(,( "          Allow Channels",($Script:htmlsb), "Email: $($RASMFASetting.ActivateEmail.ToString())",$htmlwhite))
                                $rowdata += @(,( "                        ",($Script:htmlsb), "SMS: $($RAS2FASettings.DeepnetSettings.ActivateSMS.ToString())",$htmlwhite))                                           $rowdata += @(,( "                        ",($Script:htmlsb), "SMS: $($RASMFASetting.ActivateSMS.ToString())",$htmlwhite))
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "SafeNet")                                   ElseIf($RASMFASetting.Type -eq "SafeNet")
                        {                                   {
                                Switch($RAS2FASettings.SafeNetSettings.AuthMode)                                           Switch($RASMFASetting.AuthMode)
                                {                                           {
                                        "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}                                                   "MandatoryForAllUsers"                                          {$SafeNetAuthMode = "Mandatory for all users"; Break}
                                        "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}                                                   "CreateTokenForDomainAuthenticatedUsers"        {$SafeNetAuthMode = "Create token for Domain Authenticated users"; Break}
                                        "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}                                                   "UsersWithSafeNetAcc"                                           {$SafeNetAuthMode = "Use only for users with a safe account"; Break}
                                        Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RAS2FASettings.SafeNetSettings.AuthMode)"; Break}                                                   Default                                                                         {$SafeNetAuthMode = "Safenet mode not found: $($RASMFASetting.AuthMode)"; Break}
                                }                                           }
 
                                $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite)) <>                                         $rowdata += @(,( "     Connection",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,( "          OTP Service URL",($Script:htmlsb),$RAS2FASettings.SafeNetSettings.OTPServiceURL,$htmlwhite))                                           $rowdata += @(,( "          OTP Service URL",($Script:htmlsb),$RASMFASetting.OTPServiceURL,$htmlwhite))
                                $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     Authentication",($Script:htmlsb),"",$htmlwhite))
                                $rowdata += @(,( "          Mode",($Script:htmlsb), $SafeNetAuthMode,$htmlwhite))                                           $rowdata += @(,( "          Mode",($Script:htmlsb), $SafeNetAuthMode,$htmlwhite))
                                $rowdata += @(,( "          TMS Web API URL",($Script:htmlsb), $RAS2FASettings.SafeNetSettings.TMSWebApiURL,$htmlwhite))                                           $rowdata += @(,( "          TMS Web API URL",($Script:htmlsb), $RASMFASetting.TMSWebApiURL,$htmlwhite))
                                $rowdata += @(,( "          User Repository",($Script:htmlsb), $RAS2FASettings.SafeNetSettings.UserRepository,$htmlwhite))                                           $rowdata += @(,( "          User Repository",($Script:htmlsb), $RASMFASetting.UserRepository,$htmlwhite))
                        }                                   }
                        ElseIf($RAS2FASettings.Provider -eq "GAuthTOTP")                                   ElseIf($RASMFASetting.Type -eq "GAuthTOTP")
                        {                                   {
                                Switch($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)                                           Switch($RASMFASetting.UserEnrollment)
                                {                                           {
                                        "Allow"                 {$GAuthAllow = "Allow"; Break}                                                   "Allow"                 {$GAuthAllow = "Allow"; Break}
                                        "AllowUntil"    {$GAuthAllow = "Allow until"; Break}                                                   "AllowUntil"    {$GAuthAllow = "Allow until"; Break}
                                        "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}                                                   "DoNotAllow"    {$GAuthAllow = "Do not allow"; Break}
                                        Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RAS2FASettings.GAuthTOTPSettings.UserEnrollment)"; Break}                                                   Default                 {$GAuthAllow = "Google Authenticator Allow status not found: $($RASMFASetting.UserEnrollment)"; Break}
                                }                                           }
                                                                          
                                Switch($RAS2FASettings.GAuthTOTPSettings.Tolerance)                                           Switch($RASMFASetting.Tolerance)
                                {                                           {
                                        0               {$TOTPTolerance = "None"; Break}                                                   0               {$TOTPTolerance = "None"; Break}
                                        30              {$TOTPTolerance = "+/- 30 seconds"; Break}                                                   30              {$TOTPTolerance = "+/- 30 seconds"; Break}
                                        60              {$TOTPTolerance = "+/- 60 seconds"; Break}                                                   60              {$TOTPTolerance = "+/- 60 seconds"; Break}
                                        90              {$TOTPTolerance = "+/- 90 seconds"; Break}                                                   90              {$TOTPTolerance = "+/- 90 seconds"; Break}
                                        120             {$TOTPTolerance = "+/- 120 seconds"; Break}                                                   120             {$TOTPTolerance = "+/- 120 seconds"; Break}
                                        Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}                                                   Default {$TOTPTolerance = "TOTP tolerence not found: $()"; Break}
                                }                                           }
                                                                          
                                $rowdata += @(,( "     Type Name",($Script:htmlsb),$RAS2FASettings.GAuthTOTPSettings.Type,$htmlwhite))                                           $rowdata += @(,( "     Type Name",($Script:htmlsb),$RASMFASetting.Type,$htmlwhite))
                                $rowdata += @(,( "     User Enrollment",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,( "     User Enrollment",($Script:htmlsb),"",$htmlwhite))
                                If($GAuthAllow -eq "Allow until")                                           If($GAuthAllow -eq "Allow until")
                                {                                           {
                                        $GAuthFullDate = $RAS2FASettings.GAuthTOTPSettings.UntilDateTime                                                   $GAuthFullDate = $RASMFASetting.UntilDateTime
                                        $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()                                                   $GAuthDate     = ($GAuthFullDate.ToUniversalTime()).ToShortDateString()
                                        $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()                                                   $GAuthTime     = ($GAuthFullDate.ToUniversalTime()).ToLongTimeString()
                                        $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"Date: $GAuthDate",$htmlwhite))                                                   $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"Date: $GAuthDate",$htmlwhite))
                                        $rowdata += @(,( "",($Script:htmlsb),"Time: $GAuthTime",$htmlwhite))                                                   $rowdata += @(,( "",($Script:htmlsb),"Time: $GAuthTime",$htmlwhite))
                                }                                           }
                                Else                                           Else
                                {                                           {
                                        $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"",$htmlwhite))                                                   $rowdata += @(,( "          $GAuthAllow",($Script:htmlsb),"",$htmlwhite))
                                }                                           }
                                $rowdata += @(,( "     Authentication",($Script:htmlsb), "",$htmlwhite))                                           $rowdata += @(,( "     Authentication",($Script:htmlsb), "",$htmlwhite))
                                $rowdata += @(,( "          TOTP tolerence",($Script:htmlsb), $TOTPTolerance,$htmlwhite))                                           $rowdata += @(,( "          TOTP tolerence",($Script:htmlsb), $TOTPTolerance,$htmlwhite))
                        }                                   }
 
                        If($RAS2FASettings.RestrictionMode -eq "Exclusion") <>                                 <#If($RASMFASetting.RestrictionMode -eq "Exclusion")
                        {                                   {
                                $rowdata += @(,("Enable MFA for all users except",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Enable MFA for all users except",($Script:htmlsb),"",$htmlwhite))
                        }                                   }
                        Else                                   Else
                        {                                   {
                                $rowdata += @(,("Disable MFA for all users except",($Script:htmlsb),"",$htmlwhite))                                           $rowdata += @(,("Disable MFA for all users except",($Script:htmlsb),"",$htmlwhite))
                        }                                   }#>
 
                        $msg = "Provider settings" <>                                 $msg = "Provider settings"
                        $columnWidths = @("300","175")                                   $columnWidths = @("300","175")
                        FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                        WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
 
  <>                                 <#
                        $rowdata = @()                                   $rowdata = @()
                        $columnHeaders = @("User or group list",($Script:htmlsb),$RAS2FASettings.ExcludeUserGroup.ToString(),$htmlwhite)                                   $columnHeaders = @("User or group list",($Script:htmlsb),$RASMFASetting.ExcludeUserGroup.ToString(),$htmlwhite)
                        If($RAS2FASettings.ExcludeUserGroup)                                   If($RASMFASetting.ExcludeUserGroup)
                        {                                   {
                                If($RAS2FASettings.ExcludeUserGroupList.Count -gt 0)                                           If($RASMFASetting.ExcludeUserGroupList.Count -gt 0)
                                {                                           {
                                        ForEach($Item in $RAS2FASettings.ExcludeUserGroupList)                                                   ForEach($Item in $RASMFASetting.ExcludeUserGroupList)
                                        {                                                   {
                                                $rowdata += @(,("",($Script:htmlsb),"User: $($Item.Account)",$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),"User: $($Item.Account)",$htmlwhite))
                                                $rowdata += @(,("",($Script:htmlsb),"Type: $($Item.Type)",$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),"Type: $($Item.Type)",$htmlwhite))
                                                $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),"",$htmlwhite))
                                        }                                                   }
                                }                                           }
                        }                                   }
                                                          
                        $rowdata += @(,("Client IP list",($Script:htmlsb),$RAS2FASettings.ExcludeClientIPs.ToString(),$htmlwhite))                                   $rowdata += @(,("Client IP list",($Script:htmlsb),$RASMFASetting.ExcludeClientIPs.ToString(),$htmlwhite))
                        If($RAS2FASettings.ExcludeClientIPs)                                   If($RASMFASetting.ExcludeClientIPs)
                        {                                   {
                                If($RAS2FASettings.ExcludeClientIPList.Count -gt 0)                                           If($RASMFASetting.ExcludeClientIPList.Count -gt 0)
                                {                                           {
                                        $cnt     = -1                                                   $cnt     = -1
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxFrom = (($RASMFASetting.ExcludeClientIPList.From | Measure-Object -Property length -maximum).Maximum * -1)
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxTo   = (($RASMFASetting.ExcludeClientIPList.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPList) <>                                                 ForEach($Item in $RASMFASetting.ExcludeClientIPList)
                                        {                                                   {
                                                $cnt++                                                           $cnt++
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                           $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                {                                                           {
                                                        $rowdata += @(,("     IPv4 Addresses",($Script:htmlsb),$tmp,$htmlwhite))                                                                   $rowdata += @(,("     IPv4 Addresses",($Script:htmlsb),$tmp,$htmlwhite))
                                                }                                                           }
                                                Else                                                           Else
                                                {                                                           {
                                                        $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))
                                                }                                                           }
                                        }                                                   }
                                }                                           }
                                                                          
                                If($RAS2FASettings.ExcludeClientIPv6List.Count -gt 0)                                           If($RASMFASetting.ExcludeClientIPv6List.Count -gt 0)
                                {                                           {
                                        $cnt     = -1                                                   $cnt     = -1
                                        $MaxFrom = (($RAS2FASettings.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxFrom = (($RASMFASetting.ExcludeClientIPv6List.From | Measure-Object -Property length -maximum).Maximum * -1)
                                        $MaxTo   = (($RAS2FASettings.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)                                                   $MaxTo   = (($RASMFASetting.ExcludeClientIPv6List.To | Measure-Object -Property length -maximum).Maximum * -1)
 
                                        ForEach($Item in $RAS2FASettings.ExcludeClientIPv6List) <>                                                 ForEach($Item in $RASMFASetting.ExcludeClientIPv6List)
                                        {                                                   {
                                                $cnt++                                                           $cnt++
                                                $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)                                                           $tmp = ("From: {0,$($MaxFrom)} To: {1,$($MaxTo)}" -f $Item.From, $Item.To)
                                                                                                          
                                                If($cnt -eq 0)                                                           If($cnt -eq 0)
                                                {                                                           {
                                                        $rowdata += @(,("     IPv6 Addresses",($Script:htmlsb),$tmp,$htmlwhite))                                                                   $rowdata += @(,("     IPv6 Addresses",($Script:htmlsb),$tmp,$htmlwhite))
                                                }                                                           }
                                                Else                                                           Else
                                                {                                                           {
                                                        $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))                                                                   $rowdata += @(,("",($Script:htmlsb),$tmp,$htmlwhite))
                                                }                                                           }
                                        }                                                   }
                                }                                           }
                        }                                   }
                        $rowdata += @(,("Client MAC list",($Script:htmlsb),$RAS2FASettings.ExcludeClientMAC.ToString(),$htmlwhite))                                   $rowdata += @(,("Client MAC list",($Script:htmlsb),$RASMFASetting.ExcludeClientMAC.ToString(),$htmlwhite))
                        If($RAS2FASettings.ExcludeClientMAC)                                   If($RASMFASetting.ExcludeClientMAC)
                        {                                   {
                                $cnt = -1                                           $cnt = -1
                                ForEach($MAC in $RAS2FASettings.ExcludeClientMACList)                                           ForEach($MAC in $RASMFASetting.ExcludeClientMACList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                                                                          
                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                        {                                                   {
                                                $rowdata += @(,("     MAC Address",($Script:htmlsb),$MAC,$htmlwhite))                                                           $rowdata += @(,("     MAC Address",($Script:htmlsb),$MAC,$htmlwhite))
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$MAC,$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),$MAC,$htmlwhite))
                                        }                                                   }
                                }                                           }
                        }                                   }
                        $rowdata += @(,("Connection to the following Gateway IPs",($Script:htmlsb),$RAS2FASettings.ExcludeClientGWIPs.ToString(),$htmlwhite))                                   $rowdata += @(,("Connection to the following Gateway IPs",($Script:htmlsb),$RASMFASetting.ExcludeClientGWIPs.ToString(),$htmlwhite))
                        If($RAS2FASettings.ExcludeClientGWIPs)                                   If($RASMFASetting.ExcludeClientGWIPs)
                        {                                   {
                                $cnt = -1                                           $cnt = -1
                                ForEach($Server in $RAS2FASettings.ExcludeClientGWIPList)                                           ForEach($Server in $RASMFASetting.ExcludeClientGWIPList)
                                {                                           {
                                        $cnt++                                                   $cnt++
                                                                                          
                                        If($cnt -eq 0)                                                   If($cnt -eq 0)
                                        {                                                   {
                                                $rowdata += @(,("     Server Name",($Script:htmlsb),$Server,$htmlwhite))                                                           $rowdata += @(,("     Server Name",($Script:htmlsb),$Server,$htmlwhite))
                                        }                                                   }
                                        Else                                                   Else
                                        {                                                   {
                                                $rowdata += @(,("",($Script:htmlsb),$Server,$htmlwhite))                                                           $rowdata += @(,("",($Script:htmlsb),$Server,$htmlwhite))
                                        }                                                   }
                                }                                           }
                        }                                   }
                }                                   
                $msg = "Restriction"                                   $msg = "Restriction"
                $columnWidths = @("300","175")                                   $columnWidths = @("300","175")
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths                                   FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
                WriteHTMLLine 0 0 ""                                   WriteHTMLLine 0 0 ""
                                    #>
                $rowdata = @()    
                $columnHeaders = @("Settings are replicated to all Sites",($Script:htmlsb),$RAS2FASettings.ReplicateSettings.ToString(),$htmlwhite)    
                            }
                $msg = ""                   }
                $columnWidths = @("300","175")    
                FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths    
                WriteHTMLLine 0 0 ""    
 
                        ClientStatus       = $RASAllowedDevices.AllowClientWindows <>                         ClientStatus       = $RASAllowedDevices.AllowClientAndroid
                        ClientName         = "Windows client"                           ClientName         = "Android client"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWindows                           ClientMinimumBuild = $RASAllowedDevices.MinBuildAndroid
 
                        ClientStatus       = $RASAllowedDevices.AllowClientMAC <>                         ClientStatus       = $RASAllowedDevices.AllowClientChromeApp
                        ClientName         = "macOS client"                           ClientName         = "Chrome OS client"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildMAC                           ClientMinimumBuild = $RASAllowedDevices.MinBuildChromeApp
                    }
                    
                    $AllowedDevicesWordTable += @{
                            ClientStatus       = $RASAllowedDevices.AllowClientIOS
                            ClientName         = "iOS/iPadOS client"
                            ClientMinimumBuild = $RASAllowedDevices.MinBuildIOS
 
                        ClientStatus       = $RASAllowedDevices.AllowClientIOS <>                         ClientStatus       = $RASAllowedDevices.AllowClientMAC
                        ClientName         = "iOS client"                           ClientName         = "macOS client"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildIOS                           ClientMinimumBuild = $RASAllowedDevices.MinBuildMAC
 
                        ClientStatus       = $RASAllowedDevices.AllowClientAndroid <>  
                        ClientName         = "Android client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildAndroid    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientHTML5                           ClientStatus       = $RASAllowedDevices.AllowClientWeb
                        ClientName         = "HTML5 client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildHTML5    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientChromeApp    
                        ClientName         = "Chrome client"                           ClientName         = "User Portal (Web client)"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildChromeApp                           ClientMinimumBuild = $RASAllowedDevices.MinBuildWeb
 
                        ClientStatus       = $RASAllowedDevices.AllowClientWebPortal <>                         ClientStatus       = $RASAllowedDevices.AllowClientWindows
                        ClientName         = "RAS Web Portal"                           ClientName         = "Windows client"
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWebPortal                           ClientMinimumBuild = $RASAllowedDevices.MinBuildWindows
 
                $AllowedDevicesWordTable += @{ +-  
                        ClientStatus       = $RASAllowedDevices.AllowClientJava    
                        ClientName         = "Java client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildJava    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientWinPhone    
                        ClientName         = "Windows Phone client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildWinPhone    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClientBlackberry    
                        ClientName         = "Blackberry client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuildBlackberry    
                }    
                    
                $AllowedDevicesWordTable += @{    
                        ClientStatus       = $RASAllowedDevices.AllowClient2XOS    
                        ClientName         = "2X OS client"    
                        ClientMinimumBuild = $RASAllowedDevices.MinBuild2XOS    
                }    
     
 
                Line 2 "Enabled Clients              Minimum build" <>                 Line 2 "Enabled Clients                  Minimum build"
                Line 2 "=========================================="                   Line 2 "=============================================="
                #               1234567S12345678901234567890S1234                   #               1234567S123456789012345678901234S12345
                #       False   WIndows Phone client 9999                   #       False   User Portal (Web client) 99999
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWindows, "Windows client", $RASAllowedDevices.MinBuildWindows)                   Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWindows, "Windows client", $RASAllowedDevices.MinBuildWindows)
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientMAC, "macOS client", $RASAllowedDevices.MinBuildMAC)                   Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWeb, "User Portal (Web client)", $RASAllowedDevices.MinBuildWeb)
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientLinux, "Linux client", $RASAllowedDevices.MinBuildLinux)                   Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientMAC, "macOS client", $RASAllowedDevices.MinBuildMAC)
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientIOS, "iOS client", $RASAllowedDevices.MinBuildIOS)                   Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientLinux, "Linux client", $RASAllowedDevices.MinBuildLinux)
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientAndroid, "Android client", $RASAllowedDevices.MinBuildAndroid)                   Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientIOS, "iOS/iPadOS client", $RASAllowedDevices.MinBuildIOS)
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientHTML5, "HTML5 client", $RASAllowedDevices.MinBuildHTML5)                   Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientAndroid, "Android client", $RASAllowedDevices.MinBuildAndroid)
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientChromeApp, "Chrome client", $RASAllowedDevices.MinBuildChromeApp)                   Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientChromeApp, "Chrome OS client", $RASAllowedDevices.MinBuildChromeApp)
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWebPortal, "RAS Web Portal", $RASAllowedDevices.MinBuildWebPortal)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWyse, "Wyse client", $RASAllowedDevices.MinBuildWyse)                   Line 2 ( "{0,-7} {1,-24} {2,-5}" -f $RASAllowedDevices.AllowClientWyse, "Wyse client", $RASAllowedDevices.MinBuildWyse)
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientJava, "Java client", $RASAllowedDevices.MinBuildJava)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientWinPhone, "Windows Phone client", $RASAllowedDevices.MinBuildWinPhone)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClientBlackberry, "Blackberry client", $RASAllowedDevices.MinBuildBlackberry)    
                Line 2 ( "{0,-7} {1,-20} {2,-4}" -f $RASAllowedDevices.AllowClient2XOS, "2X OS client", $RASAllowedDevices.MinBuild2XOS)    
 
  -+                 $rowdata += @(,($RASAllowedDevices.AllowClientWeb,$htmlwhite,"User Portal (Web client)",$htmlwhite,$RASAllowedDevices.MinBuildWeb,$htmlwhite))
 
                $rowdata += @(,($RASAllowedDevices.AllowClientIOS,$htmlwhite,"iOS client",$htmlwhite,$RASAllowedDevices.MinBuildIOS,$htmlwhite)) <>                 $rowdata += @(,($RASAllowedDevices.AllowClientIOS,$htmlwhite,"iOS/iPadOS client",$htmlwhite,$RASAllowedDevices.MinBuildIOS,$htmlwhite))
 
                $rowdata += @(,($RASAllowedDevices.AllowClientHTML5,$htmlwhite,"HTML5 client",$htmlwhite,$RASAllowedDevices.MinBuildHTML5,$htmlwhite)) <>  
                $rowdata += @(,($RASAllowedDevices.AllowClientChromeApp,$htmlwhite,"Chrome client",$htmlwhite,$RASAllowedDevices.MinBuildChromeApp,$htmlwhite))                   $rowdata += @(,($RASAllowedDevices.AllowClientChromeApp,$htmlwhite,"Chrome OS client",$htmlwhite,$RASAllowedDevices.MinBuildChromeApp,$htmlwhite))
                $rowdata += @(,($RASAllowedDevices.AllowClientWebPortal,$htmlwhite,"RAS Web Portal",$htmlwhite,$RASAllowedDevices.MinBuildWebPortal,$htmlwhite))    
 
                $rowdata += @(,($RASAllowedDevices.AllowClientJava,$htmlwhite,"Java client",$htmlwhite,$RASAllowedDevices.MinBuildJava,$htmlwhite)) +-  
                $rowdata += @(,($RASAllowedDevices.AllowClientWinPhone,$htmlwhite,"Windows Phone client",$htmlwhite,$RASAllowedDevices.MinBuildWinPhone,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClientBlackberry,$htmlwhite,"Blackberry client",$htmlwhite,$RASAllowedDevices.MinBuildBlackberry,$htmlwhite))    
                $rowdata += @(,($RASAllowedDevices.AllowClient2XOS,$htmlwhite,"2X OS client",$htmlwhite,$RASAllowedDevices.MinBuild2XOS,$htmlwhite))    
 
                $columnWidths = @("54","125","100") <>                 $columnWidths = @("55","175","100")
 
                $ClientOptions   = $Policy.ClientPolicy.ClientOptions <>                 <#$ClientOptions   = $Policy.ClientPolicy.ClientOptions
 
                $Session         = $Policy.ClientPolicy.Session <>                 $Session         = $Policy.ClientPolicy.Session#>
 
                $GWType = "" <>                 $GatewayType = ""
                Switch($Policy.GWRule)                   Switch($Policy.GatewayRule)
 
  <>                         "Any"                           {$GatewayType = "if Client is connected to any gateway"; Break}
                        "AnyGW"                         {$GWType = "if Client is connected to any gateway"; Break}                           "AnyGW"                         {$GatewayType = "if Client is connected to any gateway"; Break}
                            "Connected"                     {$GatewayType = "if Client is connected to one of the following gateways"; Break}
                        "ConnectedToGWs"        {$GWType = "if Client is connected to one of the following gateways"; Break}                           "ConnectedToGWs"        {$GatewayType = "if Client is connected to one of the following gateways"; Break}
                            "NotConnected"          {$GatewayType = "if Client is not connecteed to one of the following gateways"; Break}
                        "NotConnectedToGWs"     {$GWType = "if Client is not connecteed to one of the following gateways"; Break}                           "NotConnectedToGWs"     {$GatewayType = "if Client is not connecteed to one of the following gateways"; Break}
                        Default                         {$GWType = "Policy/Criteria/Gateway criteria type not found: $($Policy.GWRule)"; Break}                           Default                         {$GatewayType = "Policy/Criteria/Gateway criteria type not found: $($Policy.GatewayRule)"; Break}
 
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Gateway criteria/Apply policy"; Value = $GWType; }) > $Null <>                         $ScriptInformation.Add(@{Data = "Policy/Criteria/Gateway criteria/Apply policy"; Value = $GatewayType; }) > $Null
                        If($Policy.GWRule -ne "AnyGW")                           If($Policy.GatewayRule -ne "AnyGW")
 
                                ForEach($GW in $Policy.GWList) <>                                 ForEach($Gateway in $Policy.GatewayList)
 
                                        $ScriptInformation.Add(@{Data = ""; Value = $GW; }) > $Null <>                                         $ScriptInformation.Add(@{Data = ""; Value = $Gateway; }) > $Null
 
                        $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/HTML5"; Value = $Policy.AllowedOSes.HTML5.ToString(); }) > $Null +-  
 
  -+                         $ScriptInformation.Add(@{Data = "Policy/Criteria/Parallels client criteria/WebClient"; Value = $Policy.AllowedOSes.WebClient.ToString(); }) > $Null
 
                        Line 3 "Policy/Criteria/Gateway criteria/Apply policy: " $GWType <>                         Line 3 "Policy/Criteria/Gateway criteria/Apply policy: " $GatewayType
                        If($Policy.GWRule -ne "AnyGW")                           If($Policy.GatewayRule -ne "AnyGW")
 
                                ForEach($GW in $Policy.GWList) <>                                 ForEach($Gateway in $Policy.GatewayList)
 
                                        Line 7 "  " $GW <>                                         Line 7 "  " $Gateway
 
                        Line 3 "Policy/Criteria/Parallels client criteria/HTML5: " $Policy.AllowedOSes.HTML5.ToString() <>                         Line 3 "Policy/Criteria/Parallels client criteria/WebClient: " $Policy.AllowedOSes.WebClient.ToString()
 
                        $columnHeaders = @("Policy/Criteria/Gateway criteria/Apply policy",($Script:htmlsb),$GWType,$htmlwhite) <>                         $columnHeaders = @("Policy/Criteria/Gateway criteria/Apply policy",($Script:htmlsb),$GatewayType,$htmlwhite)
                        If($Policy.GWRule -ne "AnyGW")                           If($Policy.GatewayRule -ne "AnyGW")
 
                                ForEach($GW in $Policy.GWList) <>                                 ForEach($Gateway in $Policy.GatewayList)
 
                                        $rowdata += @(,("",($Script:htmlsb),$GW,$htmlwhite)) <>                                         $rowdata += @(,("",($Script:htmlsb),$Gateway,$htmlwhite))
 
                        $rowdata += @(,("Policy/Criteria/Parallels client criteria/HTML5",($Script:htmlsb),$Policy.AllowedOSes.HTML5.ToString(),$htmlwhite)) <>                         $rowdata += @(,("Policy/Criteria/Parallels client criteria/WebClient",($Script:htmlsb),$Policy.AllowedOSes.WebClient.ToString(),$htmlwhite))
 
                                $GWMode = "" <>                                 $GatewayMode = ""
 
                                        "DirectMode"            {$GWMode = "Direct Mode"; Break} <>                                         "DirectMode"            {$GatewayMode = "Direct Mode"; Break}
                                        "DirectSSLMode"         {$GWMode = "Direct SSL Mode"; Break}                                           "DirectSSLMode"         {$GatewayMode = "Direct SSL Mode"; Break}
                                        "GatewayMode"           {$GWMode = "Gateway Mode"; Break}                                           "GatewayMode"           {$GatewayMode = "Gateway Mode"; Break}
                                        "GatewaySSLMode"        {$GWMode = "Gateway SSL Mode"; Break}                                           "GatewaySSLMode"        {$GatewayMode = "Gateway SSL Mode"; Break}
                                        Default                         {$GWMode = "Secondary connections/Secondary connections/Mode not found: $($Item.Mode)"; Break}                                           Default                         {$GatewayMode = "Secondary connections/Secondary connections/Mode not found: $($Item.Mode)"; Break}
 
                                                Value = "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())"; <>                                                 Value = "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())";
 
                                                "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())",$htmlwhite)) <>                                                 "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())",$htmlwhite))
 
                                                OutputPolicySetting $txt "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())" <>                                                 OutputPolicySetting $txt "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())"
 
                                                Value = "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())"; <>                                                 Value = "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())";
 
                                                "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())",$htmlwhite)) <>                                                 "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())",$htmlwhite))
 
                                                OutputPolicySetting "`t`t`t`t`t`t`t      " "Connection: $($Item.Server)   Mode: $GWMode   Port: $($Item.ServerPort.ToString())" <>                                                 OutputPolicySetting "`t`t`t`t`t`t`t      " "Connection: $($Item.Server)   Mode: $GatewayMode   Port: $($Item.ServerPort.ToString())"
 
                Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Disk drives" <>                 Write-Verbose "$(Get-Date -Format G): `t`t`t`tSession/Local devices and resources/Disk drives and folders"
 
                        $txt = "Session/Local devices and resources/Disk drives/Disk drives/Allow disk drives redirection" <>                         $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Allow disk drives redirection"
 
                        $txt = "Session/Local devices and resources/Disk drives/Disk drives/Use all disk drives available" <>                         $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Use all disk drives available"
 
                        $txt = "Session/Local devices and resources/Disk drives/Disk drives/Use also disk drives that I plug in later" <>                         $txt = "Session/Local devices and resources/Disk drives and folders/Disk drives and folders/Use also disk drives that I plug in later"
 
                        If($Policy.ClientPolicy.ClientOptions.Logging.LogLevel -ne "Verbose")   #Verbose from PoSH equals Standard in the console - weird <>                         If($Policy.ClientPolicy.ClientOptions.Logging.LogLevel -ne "Standard")
 
  -+                                         0               {$LogDuration = ""; Break}
 
                        $txt = "Client options/Advanced/Printing/Redirect custom paper sizes when server preferences are selected" <>                         <#$txt = "Client options/Advanced/Printing/Redirect custom paper sizes when server preferences are selected"
 
                        } <>                         }#>
 
                                $columnWidths = @("400","300") <>                                 $columnWidths = @("600","300")
 
        $RASFeatures = Get-RASSystemSettings -EA 0 4>$Null <>         $RASFeatures = Get-RASHelpdeskEmailSettings -EA 0 4>$Null
 
  <>         }
     
            Write-Verbose "$(Get-Date -Format G): `tProcessing Settings"
            
            $GotRASSettings = $False
            $RASSettings = Get-RASSystemSettings -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASsettings)
            {
                    Write-Host "
                    No settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No settings information was found"
                    }
            }
            Else
            {
                    $GotRASSettings = $True
                OutputRASSettings $RASFeatures                   OutputRASSettings $RASSettings
 
  -+         $RASProxySettings = Get-RASProxySettings -EA 0 4>$Null
            
            If(!($?))
            {
                    Write-Warning "
                    `n
                    Unable to retrieve Proxy settings information
                    "
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "Unable to retrieve Proxy settings information"
                    }
                    If($Text)
                    {
                            Line 0 "Unable to retrieve Proxy settings information"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "Unable to retrieve Proxy settings information"
                    }
            }
            ElseIf($? -and $null -eq $RASProxySettings)
            {
                    Write-Host "
                    No Proxy settings information was found
                    " -ForegroundColor White
                    If($MSWord -or $PDF)
                    {
                            WriteWordLine 0 0 "No Proxy settings information was found"
                    }
                    If($Text)
                    {
                            Line 0 "No Proxy settings information was found"
                    }
                    If($HTML)
                    {
                            WriteHTMLLine 0 0 "No Proxy settings information was found"
                    }
            }
            Else
            {
                    OutputRASProxySettings $RASProxySettings
            }
     
            If($GotRASSettings)
            {
                    OutputRASMiscSettings $RASSettings
            }
            
 
        Param([object] $RASFeatures) <>         Param([object] $RASSettings)
 
                $ScriptInformation.Add(@{Data = "Participate in the Customer Experience Program"; Value = $RASFeatures.CEPEnabled.ToString(); }) > $Null <>                 $ScriptInformation.Add(@{Data = "Participate in the Customer Experience Program"; Value = $RASSettings.CEPEnabled.ToString(); }) > $Null
 
                Line 3 "Participate in the Customer Experience Program`t`t: " $RASFeatures.CEPEnabled.ToString() <>                 Line 3 "Participate in the Customer Experience Program`t`t: " $RASSettings.CEPEnabled.ToString()
 
                $columnHeaders = @("Participate in the Customer Experience Program",($Script:htmlsb),$RASFeatures.CEPEnabled.ToString(),$htmlwhite) <>                 $columnHeaders = @("Participate in the Customer Experience Program",($Script:htmlsb),$RASSettings.CEPEnabled.ToString(),$htmlwhite)
 
  -+ }
 
  -+ Function OutputRASProxySettings
    {
            Param([object] $RASProxySettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput HTTP Proxy Settings"
            
 
                If($RASFeatures.HttpProxyMode -eq "NoProxy") <>                 If($RASProxySettings.HttpProxyMode -eq "NoProxy")
 
                        $ScriptInformation.Add(@{Data = "Address"; Value = $RASFeatures.HttpProxyAddress; }) > $Null <>                         $ScriptInformation.Add(@{Data = "Address"; Value = $RASProxySettings.HttpProxyAddress; }) > $Null
                        $ScriptInformation.Add(@{Data = "Port"; Value = $RASFeatures.HttpProxyPort; }) > $Null                           $ScriptInformation.Add(@{Data = "Port"; Value = $RASProxySettings.HttpProxyPort; }) > $Null
                        $ScriptInformation.Add(@{Data = "User name"; Value = $RASFeatures.HttpProxyUser; }) > $Null                           $ScriptInformation.Add(@{Data = "User name"; Value = $RASProxySettings.HttpProxyUser; }) > $Null
                        $ScriptInformation.Add(@{Data = "Password"; Value = $RASFeatures.HttpProxyPwd; }) > $Null                           $ScriptInformation.Add(@{Data = "Password"; Value = $RASProxySettings.HttpProxyPwd; }) > $Null
 
                If($RASFeatures.HttpProxyMode -eq "NoProxy") <>                 If($RASProxySettings.HttpProxyMode -eq "NoProxy")
 
                        Line 3 "Address`t`t: " $RASFeatures.HttpProxyAddress <>                         Line 3 "Address`t`t: " $RASProxySettings.HttpProxyAddress
                        Line 3 "Port`t`t: " $RASFeatures.HttpProxyPort                           Line 3 "Port`t`t: " $RASProxySettings.HttpProxyPort
                        Line 3 "User name`t: " $RASFeatures.HttpProxyUser                           Line 3 "User name`t: " $RASProxySettings.HttpProxyUser
                        Line 3 "Password`t: " $RASFeatures.HttpProxyPwd                           Line 3 "Password`t: " $RASProxySettings.HttpProxyPwd
 
                If($RASFeatures.HttpProxyMode -eq "NoProxy") <>                 If($RASProxySettings.HttpProxyMode -eq "NoProxy")
 
                        $rowdata += @(,("Address",($Script:htmlsb),$RASFeatures.HttpProxyAddress,$htmlwhite)) <>                         $rowdata += @(,("Address",($Script:htmlsb),$RASProxySettings.HttpProxyAddress,$htmlwhite))
                        $rowdata += @(,("Port",($Script:htmlsb),$RASFeatures.HttpProxyPort.ToString(),$htmlwhite))                           $rowdata += @(,("Port",($Script:htmlsb),$RASProxySettings.HttpProxyPort.ToString(),$htmlwhite))
                        $rowdata += @(,("User name",($Script:htmlsb),$RASFeatures.HttpProxyUser,$htmlwhite))                           $rowdata += @(,("User name",($Script:htmlsb),$RASProxySettings.HttpProxyUser,$htmlwhite))
                        $rowdata += @(,("Password",($Script:htmlsb),$RASFeatures.HttpProxyPwd,$htmlwhite))                           $rowdata += @(,("Password",($Script:htmlsb),$RASProxySettings.HttpProxyPwd,$htmlwhite))
 
  -+ }
 
  -+ Function OutputRASMiscSettings
    {
            Param([object] $RASSettings)
            
            Write-Verbose "$(Get-Date -Format G): `t`tOutput Miscellaneous Settings"
            
 
        Switch ($RASFeatures.ResetIdleSessionAfterMins) <>         Switch ($RASSettings.ResetIdleSessionAfterMins)
 
                0               {$RASFeaturesResetIdleSessionAfterMins = "Never"; Break} <>                 0               {$RASSettingsResetIdleSessionAfterMins = "Never"; Break}
                15              {$RASFeaturesResetIdleSessionAfterMins = "15 minutes"; Break}                   15              {$RASSettingsResetIdleSessionAfterMins = "15 minutes"; Break}
                30              {$RASFeaturesResetIdleSessionAfterMins = "30 minutes"; Break}                   30              {$RASSettingsResetIdleSessionAfterMins = "30 minutes"; Break}
                60              {$RASFeaturesResetIdleSessionAfterMins = "1 hour"; Break}                   60              {$RASSettingsResetIdleSessionAfterMins = "1 hour"; Break}
                180             {$RASFeaturesResetIdleSessionAfterMins = "3 hours"; Break}                   180             {$RASSettingsResetIdleSessionAfterMins = "3 hours"; Break}
                360             {$RASFeaturesResetIdleSessionAfterMins = "6 hours"; Break}                   360             {$RASSettingsResetIdleSessionAfterMins = "6 hours"; Break}
                720             {$RASFeaturesResetIdleSessionAfterMins = "12 hours"; Break}                   720             {$RASSettingsResetIdleSessionAfterMins = "12 hours"; Break}
                1440    {$RASFeaturesResetIdleSessionAfterMins = "1 day"; Break}                   1440    {$RASSettingsResetIdleSessionAfterMins = "1 day"; Break}
                Default {$RASFeaturesResetIdleSessionAfterMins = "Unable to determine Console idle time: $($RASFeatures.ResetIdleSessionAfterMins)"; Break}                   Default {$RASSettingsResetIdleSessionAfterMins = "Unable to determine Console idle time: $($RASSettings.ResetIdleSessionAfterMins)"; Break}
 
                $ScriptInformation.Add(@{Data = "Reset idle RAS Console session after"; Value = $RASFeaturesResetIdleSessionAfterMins; }) > $Null <>                 $ScriptInformation.Add(@{Data = "Reset idle RAS Console session after"; Value = $RASSettingsResetIdleSessionAfterMins; }) > $Null
 
                Line 3 "Reset idle RAS Console session after`t`t`t: " $RASFeaturesResetIdleSessionAfterMins <>                 Line 3 "Reset idle RAS Console session after`t`t`t: " $RASSettingsResetIdleSessionAfterMins
 
                $columnHeaders = @("Reset idle RAS Console session after",($Script:htmlsb),$RASFeaturesResetIdleSessionAfterMins,$htmlwhite) <>                 $columnHeaders = @("Reset idle RAS Console session after",($Script:htmlsb),$RASSettingsResetIdleSessionAfterMins,$htmlwhite)
 
  -+                 "3"                                     {$RASMailboxSettingsUseTLS = "Use TLS 1.2 if available"; Break}
 
                        "RDSHConnectSessionEvent"               {$RASNotificationText = "RDSH sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break} <>                         "RDSHConnectSessionEvent"               {$RASNotificationText = "RDSH active sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}
 
  <>                         "34660353"                                              {$RASNotificationText = "AVD active sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold) %"; Break}
                            "34660354"                                              {$RASNotificationText = "AVD disconnected sessions utilization $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}
                        "TunneledSess"                                  {$RASNotificationText = "Number of gateway tunnelled sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}                           "TunneledSess"                                  {$RASNotificationText = "Number of Secure Gateway tunnelled sessions $RASNotificationHandlerDirection $($RASNotificationHandler.Threshold)"; Break}
                        "GW"                                                    {$RASNotificationText = "Failed gateway tunnelled sessions"; Break}                           "GW"                                                    {$RASNotificationText = "Failed Secure Gateway tunnelled sessions"; Break}
                        "1097729"                                               {$RASNotificationText = "Failed gateway tunnelled sessions"; Break}                           "1097729"                                               {$RASNotificationText = "Failed Secure Gateway tunnelled sessions"; Break}
 
                        "45056"                                                 {$RASNotificationText = "Tenants"; Break} <>                         "45056"                                                 {$RASNotificationText = "Tenants events"; Break}
 
  +-  
                        #"CPU"                                                  {$RASNotificationText = ""; Break}    
                        #"Disk"                                                 {$RASNotificationText = ""; Break}    
                        #"Memory"                                               {$RASNotificationText = ""; Break}    
                        #"RDSH"                                                 {$RASNotificationText = ""; Break}    
 
                $GracePeriod           = ($RASNotificationHandler.GracePeriod / 60) <>                 $GracePeriod           = ($RASNotificationHandler.GracePeriod.ToString())
                $NotificationsInterval = ($RASNotificationHandler.Interval / 60)                   $NotificationsInterval = ($RASNotificationHandler.Interval.ToString())
 
                        $columnWidths = @("200","225") <>                         $columnWidths = @("250","225")
 
  -+ }
     
    Function OutputRASClientSettings
    {
            Param([object] $RASClientSettings)
     
            <#
            ExcludeDirectRDP         :
            ExcludeDirectRDPForVDI   :
            SendHDIcons              : True
            ReplicateSendHDIcons     : True
            EnableOverlayIcons       : True
            ShowPasswordExpiry       : False
            TokenValidationExpireMin : 60
            #>
     
            If($MSWord -or $PDF)
            {
                    WriteWordLine 3 0 "Client settings"
                    $ScriptInformation = New-Object System.Collections.ArrayList
                    $ScriptInformation.Add(@{Data = "Published application icons"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Resolution:"; Value = ""; }) > $Null
                    If($RASClientSettings.SendHDIcons)
                    {
                            $ScriptInformation.Add(@{Data = "          High resolution icons (uses more network bandwidth)"; Value = ""; }) > $Null
                    }
                    Else
                    {
                            $ScriptInformation.Add(@{Data = "          Standard resolution icons"; Value = ""; }) > $Null
                    }
                    $ScriptInformation.Add(@{Data = "     Overlay:"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "          $($RASClientSettings.EnableOverlayIcons.ToString())"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "Password notifications"; Value = ""; }) > $Null
                    $ScriptInformation.Add(@{Data = "     Show password expiration reminder"; Value = $RASClientSettings.ShowPasswordExpiry.ToString(); }) > $Null
                    $ScriptInformation.Add(@{Data = "Settings are replicated to all Sites"; Value = $RASClientSettings.ReplicateSendHDIcons.ToString(); }) > $Null
     
                    $Table = AddWordTable -Hashtable $ScriptInformation `
                    -Columns Data,Value `
                    -List `
                    -Format $wdTableGrid `
                    -AutoFit $wdAutoFitFixed;
     
                    SetWordCellFormat -Collection $Table -Size 10 -BackgroundColor $wdColorWhite
                    SetWordCellFormat -Collection $Table.Columns.Item(1).Cells -Bold -BackgroundColor $wdColorGray15;
     
                    $Table.Columns.Item(1).Width = 200;
                    $Table.Columns.Item(2).Width = 250;
     
                    $Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
     
                    FindWordDocumentEnd
                    $Table = $Null
     
                    WriteWordLine 0 0 ""
            }
            If($Text)
            {
                    Line 2 "Client settings"
                    Line 3 "Published application icons"
                    Line 4 "Resolution:"
                    If($RASClientSettings.SendHDIcons)
                    {
                            Line 5 "High resolution (uses more network bandwidth)"
                    }
                    Else
                    {
                            Line 5 "Standard resolution"
                    }
                    Line 4 "Overlay:"
                    Line 5 "Enable overlay icon`t : " $RASClientSettings.EnableOverlayIcons.ToString()
                    LIne 3 "Password notifications"
                    Line 4 "Show password expiration reminder: " $RASClientSettings.ShowPasswordExpiry.ToString()
                    Line 3 "Settings are replicated to all Sites`t : " $RASClientSettings.ReplicateSendHDIcons.ToString()
                    Line 0 ""
            }
            If($HTML)
            {
                    WriteHTMLLine 3 0 "Client settings"
                    $rowdata = @()
                    $columnHeaders = @("Published application icons",($Script:htmlsb),"S",$htmlwhite)
                    $rowdata += @(,("     Resolution:",($Script:htmlsb),"",$htmlwhite))
                    If($RASClientSettings.SendHDIcons)
                    {
                            $rowdata += @(,("          High resolution (uses more network bandwidth)",($Script:htmlsb),"",$htmlwhite))
                    }
                    Else
                    {
                            $rowdata += @(,("          Standard resolution",($Script:htmlsb),"",$htmlwhite))
                    }
                    $rowdata += @(,("     Overlay:",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("          $($RASClientSettings.EnableOverlayIcons.ToString())",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("Password notifications",($Script:htmlsb),"",$htmlwhite))
                    $rowdata += @(,("     Show password expiration reminder",($Script:htmlsb),$RASClientSettings.ShowPasswordExpiry.ToString(),$htmlwhite))
                    $rowdata += @(,("Settings are replicated to all Sites",($Script:htmlsb),$RASClientSettings.ReplicateSendHDIcons.ToString(),$htmlwhite))
     
                    $msg = ""
                    $columnWidths = @("200","275")
                    FormatHTMLTable $msg "auto" -rowArray $rowdata -columnArray $columnHeaders -fixedWidth $columnWidths
     
                    WriteHTMLLine 0 0 ""
            }
     
 
SetFilenames "Parallels_RAS" +-  
     
 
  -+  
    SetFilenames "Parallels_RAS_$Script:RASFarmName"
     
    OutputFarm
 
ProcessPolicies #new in 18.1 <> ProcessPolicies